delphi中:
Function ShowZongPou():WordBool;export;var
Form1: TForm1;implementation{$R *.dfm}Function Show():WordBool; begin
try
Form1:=TForm1.Create(Application);
form1.ShowModal;
finally
form1.free;
end;
end;vc6中:
typedef bool (__stdcall *MYPROC)();
HINSTANCE hinstLib;
MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
// Get a handle to the DLL module.
hinstLib = LoadLibrary("Project.dll");
// If the handle is valid, try to get the function address.
if (hinstLib != NULL)
{
ProcAdd = (MYPROC) GetProcAddress(hinstLib, "Show");
// If the function address is valid, call the function.
if (fRunTimeLinkSuccess = (ProcAdd != NULL))
(ProcAdd) ();
// Free the DLL module.
fFreeResult = FreeLibrary(hinstLib);
}
// If unable to call the DLL function, use an alternative.
if (! fRunTimeLinkSuccess)
printf("message via alternative method\n"); 运行时报错:
Access violation at address 00d8a1f1 in module 'project.dll'.Write of address 000001f8
Function ShowZongPou():WordBool;export;var
Form1: TForm1;implementation{$R *.dfm}Function Show():WordBool; begin
try
Form1:=TForm1.Create(Application);
form1.ShowModal;
finally
form1.free;
end;
end;vc6中:
typedef bool (__stdcall *MYPROC)();
HINSTANCE hinstLib;
MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
// Get a handle to the DLL module.
hinstLib = LoadLibrary("Project.dll");
// If the handle is valid, try to get the function address.
if (hinstLib != NULL)
{
ProcAdd = (MYPROC) GetProcAddress(hinstLib, "Show");
// If the function address is valid, call the function.
if (fRunTimeLinkSuccess = (ProcAdd != NULL))
(ProcAdd) ();
// Free the DLL module.
fFreeResult = FreeLibrary(hinstLib);
}
// If unable to call the DLL function, use an alternative.
if (! fRunTimeLinkSuccess)
printf("message via alternative method\n"); 运行时报错:
Access violation at address 00d8a1f1 in module 'project.dll'.Write of address 000001f8
发表于:2007-09-17 00:37:03 楼主
delphi中:
Function ShowZongPou():WordBool;stdcall; var
Form1: TForm1; implementation {$R *.dfm} Function Show():WordBool;stdcall; begin
try
Form1:=TForm1.Create(Application);
form1.ShowModal;
finally
form1.free;
end;
end; exports
Show;
TApplication.Handle:=AHandle;
AHandle为函数的参数