天黑了去裸奔 发表于 2011-12-27 12:14:00

动态调用的几种写法

1 var
TempGetWindowsDirectory : function (lpBuffer: PChar; uSize: UINT): UINT; stdcall;
begin
TempGetWindowsDirectory := GetProcAddress(LoadLibrary('kernel32.dll'),'GetWindowsDirectoryA');
end;
2
var
TempGetWindowsDirectory:function (lpBuffer: PChar; uSize: UINT): UINT; stdcall;
begin
@TempGetWindowsDirectory:= GetProcAddress(LoadLibrary('kernel32.dll'),'GetWindowsDirectoryA');
end;
3
var
TempHWND:HWND;//存取DLL返回的句柄
TempGetWindowsDirectory : function (lpBuffer: PChar; uSize: UINT): UINT; stdcall;
TempWord:LPCSTR;
begin
TempWord := 'GetWindowsDirectoryA';
TempHWND := LoadLibrary('kernel32.dll');
TempGetWindowsDirectory := GetProcAddress(TempHWND,TempWord);
end;
4
type
TempGetWindowsDirectory = function (lpBuffer: PChar; uSize: UINT): UINT; stdcall;
var
TempHWND:HWND;
TempWord:LPCSTR;
MSDirectory:TempGetWindowsDirectory;
bagin
TempWord := 'GetWindowsDirectoryA';
TempHWND := LoadLibrary('kernel32.dll');
MSDirectory :=GetProcAddress(TempHWND,TempWord);
end;


huigezi 发表于 2011-12-27 13:00:36

这不是VC的吧?
页: [1]
查看完整版本: 动态调用的几种写法