请教在DELPHI中如何调用C语言的DLL文件
1个回答
展开全部
DELPHI可以调用任何语言写的DLL文件,调用的方法例子代码:
var
psapi: cardinal;
//下面申明DLL中子程序的原型
EnumProcesses: function (lpidProcess, cb, cbNeeded: DWORD): Integer; stdcall;
EnumProcessModules: function (hProcess: THandle; lphModule: HMODULE; cb, lpcbNeeded: DWORD): Integer; stdcall;
GetModuleBaseNameA: function (hProcess: THandle; HMODULE: HMODULE; lpBaseName: PChar; nSize: DWORD): Integer; stdcall;
GetModuleFileNameExA: function (hProcess: THandle; HMODULE: HMODULE; lpFileName: PChar; nSize: DWORD): Integer; stdcall;
begin
//打开PSAPI.DLL文件
psapi:=LoadLibrary('psapi');
if psapi<>0 then
try
//把函数原型与DLL关联
EnumProcesses:=GetProcAddress(psapi,'EnumProcesses');
EnumProcessModules:=GetProcAddress(psapi,'EnumProcessModules');
GetModuleBaseNameA:=GetProcAddress(psapi,'GetModuleBaseNameA');
GetModuleFileNameExA:=GetProcAddress(psapi,'GetModuleFileNameExA');
//执行审核的函数
if (@GetModuleBaseNameA<>nil) and (@GetModuleFileNameExA<>nil) and (@EnumProcessModules<>nil) and (@EnumProcesses<>nil) then
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询