如何引用DLL文件中的函数?(100分)

  • 主题发起人 主题发起人 ymkj
  • 开始时间 开始时间
Y

ymkj

Unregistered / Unconfirmed
GUEST, unregistred user!
在VC++中函数引用方法如下:
LPVOID DRAWFRM_Init(HWND hWnd ,COLORREF ColorKey, DWORD
dwWidth ,DWORD dwHeight, DWORD *pdwMethod , char *RegistryPath);
DWORD DRAWFRM_Show(LPVOID lpObject, LPBYTE buffer, RECT rDestRect);
BOOL DRAWFRM_ChangeWidthHigh(int iWidth,int iHigh);
BOOL DRAWFRM_Close(LPVOID lpObject );

在DELPHI中写法如下:
unit main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, ComCtrls, FileCtrl;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;
implementation

uses drawform;
function DRAWFRM_Init(hwnd:string;colorkey:dword;width,high:integer;pdwmethod:pointer;registrypath:pointer):string;stdcall;external 'DrawFrm.dll' NAME 'DRAWFRM_Init';
function DRAWFRM_Show(lpObject:string;buffer:byte;rcDest:string):integer;stdcall;external 'DrawFrm.dll' NAME 'DRAWFRM_Init';
function DRAWFRM_ChangeWidthHigh(iWidth,iHigh:integer):integer;stdcall;external 'DrawFrm.dll' NAME 'DRAWFRM_ChangeWidthHigh';
function DRAWFRM_Close(lpObject:byte):byte;stdcall;external 'DrawFrm.dll' NAME 'DRAWFRM_Close';
{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
asd:string;
pdwmethod:^dword;
registrypath:^string;
begin

form2.Show;
asd:='form2.panel1';
DRAWFRM_Init(asd,null,320,240,pdwmethod,registrypath);
end;

end.

到此出错,无法向下写。如何才能在DELPHI中将这四个函数引用。
 
试试:
function DRAWFRM_Init(Handle: HWnd;ColorKey: DWORD;
dwWidth, dwHeight: DWORD;
pdwMethod: PDWORD;
RegistryPath : PChar): Pointer;stdcall;external 'DrawFrm.dll' NAME 'DRAWFRM_Init';
function DRAWFRM_Show(lpObject: Pointer;
Buffer: PChar;
rDestRect: TRect): DWORD;
stdcall;external 'DrawFrm.dll' NAME 'DRAWFRM_Show';
function DRAWFRM_ChangeWidthHeight(iWidth, iHeight: Integer): Bool;
stdcall;external 'DrawFrm.dll' NAME 'DRAWFRM_ChangeWidthHeight';
function DRAWFRM_Close(lpObject: Pointer): Bool;
stdcall;external 'DrawFrm.dll' NAME 'DRAWFRM_Close';
 
接受答案了.
 
后退
顶部