如果是别的Dll中的函数就需要通过声明的方式调用该DLL中的函数,方法有两种:
1.静态调用:
在implementation的下一行添加这个函数的声明...
例如:
function RegisterServiceProcess(dwProcessID, dwType: Integer): Integer; stdcall; external 'KERNEL32.DLL';
这个例子的就是声明在'KERNEL32.DLL'中的RegisterServiceProcess函数,声明后你就可以在程序中调用它了.
2.动态调用:
在一个过程或函数中,例如还是上面那个函数
procedure ...
var
RegServPro:Function(dwProcessID, dwType: DWord):DWord;Stdcall;
begin
aLib:=LoadLibrary('Kernel32.dll');
IF aLib>=32 then
begin
@RegServPro:=GetProcAddress(aLib,'RegisterServiceProcess');
IF @RegServPro<>nil then
RegServPro(GetCurrentProcessID,1); //这里使用了这个函数...
FreeLibrary(aLib);
end;
eng;
如果是别的Dll中的函数就需要通过声明的方式调用该DLL中的函数,方法有两种:
1.静态调用:
在implementation的下一行添加这个函数的声明...
例如:
function RegisterServiceProcess(dwProcessID, dwType: Integer): Integer; stdcall; external 'KERNEL32.DLL';
这个例子的就是声明在'KERNEL32.DLL'中的RegisterServiceProcess函数,声明后你就可以在程序中调用它了.
2.动态调用:
在一个过程或函数中,例如还是上面那个函数
procedure ...
var
RegServPro:Function(dwProcessID, dwType: DWord):DWord;Stdcall;
begin
aLib:=LoadLibrary('Kernel32.dll');
IF aLib>=32 then
begin
@RegServPro:=GetProcAddress(aLib,'RegisterServiceProcess');
IF @RegServPro<>nil then
RegServPro(GetCurrentProcessID,1); //这里使用了这个函数...
FreeLibrary(aLib);
end;
eng;