[fpc-pascal] Problem compiling DLL for 64Bit Windows - complete example attached

Lukas Gradl fpc at ssn.at
Fri Dec 18 13:39:45 CET 2009

>  >   rMonitor=packed record
> ...
>>   end;
>>   rMonitorEx=packed record
>>     dwMonitorSize:DWORD;
>>     Monitor:rMonitor;
>>   end;
> Are you sure the C record is packed too ? This would mean that all 
> function pointers in rMonitor are not aligned.

I'm not shure about that as I'm not that good at C. The packed record 
works at 32bit -so I thought that should be correct.

Is there a difference between 64Bit and 32Bit?

Here is the orginal C definition, could someone take a look at this:

typedef struct _MONITOR {
   BOOL (WINAPI *pfnEnumPorts)
        (LPWSTR pName, DWORD Level, LPBYTE  pPorts, DWORD cbBuf,
         LPDWORD pcbNeeded, LPDWORD pcReturned);
   BOOL (WINAPI *pfnOpenPort)
        (LPWSTR pName, PHANDLE pHandle);
   BOOL (WINAPI *pfnOpenPortEx)
        (LPWSTR  pPortName, LPWSTR pPrinterName, PHANDLE pHandle,
         struct _MONITOR FAR *pMonitor);
   BOOL (WINAPI *pfnStartDocPort)
        (HANDLE hPort, LPWSTR pPrinterName, DWORD JobId,
         DWORD Level, LPBYTE  pDocInfo);
   BOOL (WINAPI *pfnWritePort)
        (HANDLE hPort, LPBYTE pBuffer, DWORD cbBuf,
         LPDWORD pcbWritten);
   BOOL (WINAPI *pfnReadPort)
        (HANDLE hPort, LPBYTE pBuffer, DWORD cbBuffer,
         LPDWORD pcbRead);
   BOOL (WINAPI *pfnEndDocPort)
        (HANDLE hPort);
   BOOL (WINAPI *pfnClosePort)
        (HANDLE hPort);
   BOOL (WINAPI *pfnAddPort)
        (LPWSTR pName, HWND hWnd, LPWSTR pMonitorName);
   BOOL (WINAPI *pfnAddPortEx)
        (LPWSTR pName, DWORD Level, LPBYTE lpBuffer,
         LPWSTR lpMonitorName);
   BOOL (WINAPI *pfnConfigurePort)
        (LPWSTR pName, HWND hWnd, LPWSTR pPortName);
   BOOL (WINAPI *pfnDeletePort)
        (LPWSTR pName, HWND hWnd, LPWSTR pPortName);
   BOOL (WINAPI *pfnGetPrinterDataFromPort)
        (HANDLE hPort, DWORD ControlID, LPWSTR pValueName,
         LPWSTR lpInBuffer, DWORD cbInBuffer, LPWSTR lpOutBuffer,
         DWORD cbOutBuffer, LPDWORD lpcbReturned);
   BOOL (WINAPI *pfnSetPortTimeOuts)
         DWORD reserved    // must be set to 0);
   BOOL (WINAPI *pfnXcvOpenPort)
        (LPCWSTR pszObject, ACCESS_MASK GrantedAccess, PHANDLE phXcv);
   DWORD (WINAPI *pfnXcvDataPort)
         (HANDLE  hXcv, LPCWSTR pszDataName, PBYTE pInputData,
          DWORD cbInputData, PBYTE pOutputData, DWORD cbOutputData,
          PDWORD pcbOutputNeeded);
   BOOL (WINAPI *pfnXcvClosePort)
        (HANDLE  hXcv);

typedef struct _MONITOREX {
   DWORD  dwMonitorSize;
   MONITOR  Monitor;



software security networks
Lukas Gradl <fpc#ssn.at>
Eduard-Bodem-Gasse 5
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21

More information about the fpc-pascal mailing list