DLL 的头文件如下:
#ifdef __cplusplus
#define EXPORT extern "C" __declspec(dllexport) VRT_FA 
#else
#define EXPORT __declspec(dllexport) VRT_FA
#endif
#define int VRT_FAEXPORT  FA_BeforeEncode(
HWND hWndParent, //Input
LPCTSTR pszFiles[], //Input
int cbOutFileSize, //Input
LPTSTR pszOutFiles[] //Output
)封装DLL后,在VC调用没问题,但在DEPHI 调用时参数 cbOutFileSize没法传进,其它三个没问题。在VC调试DLL时,发现cbOutFileSize为 2 。
在DEPHI 的调用代码如下:type TFA_BeforeEncode = function(
  hWndParent: hwnd; //Input
  pszFiles: array of string; //Input
cbOutFileSize: integer; //Input
pszOutFiles: array of string //Output
  ):integer; cdecl;
procedure TForm1.Button1Click(Sender: TObject);
var
  hLib: HMODULE;
  FA_BeforeEncode:TFA_BeforeEncode;
  hWndParent: hwnd;
  pszFiles: array of string ;
  pszOutFiles: array of string;
  cbOutFileSize:integer;
BEGIN  hLib := LoadLibrary('FA_API.dll');
  Setlength(pszFiles,3);
  Setlength(pszOutFiles,3);
  cbOutFileSize:=256;
  pszFiles[0]:='c:\test1.txt';
  pszFiles[1]:='c:\test2.txt';
  pszFiles[2]:='';
  hWndParent:=form1.Handle;
  try
    FA_BeforeEncode := GetProcAddress(hLib,'FA_BeforeEncode');
    if (@FA_BeforeEncode <> nil) then
        FA_BeforeEncode(hWndParent,pszFiles,cbOutFileSize,pszOutFiles);
  finally
  FreeLibrary(hLib);//
  end;END.