GetModuleHandle()函数的含义: 获得一个模块(exe或dll)的句柄。
-----------------------------------------------------------------------------------------
GetModuleHandle(
lpModuleName: PChar
): HMODULE;
..........................................................................................................
例子
..........................................................................................................
//获取当前模块的句柄
var
s: string;
h: Cardinal;
begin
s:= Application.ExeName;
s:=ExtractFileName(s);
{获取参数是要模块名称就够了,不需要路径}
h:=GetModuleHandle(Pchar(s));
showMessage(IntToStr(h));
end;
............................................................................................................
//用 nil 做参数即可获得当前模块的句柄
var
h:Cardinal;
begin
h:=GetModuleHandle(ni);
showMessage(IntToStr(h));
end;
...............................................................................................................
//获取系统骨干模块Gdi32.dll的句柄
var
h: Cardinal;
begin
h:GetModuleHandle('Gdi32.dll');
showMessage(IntToStr(h));
end;
...............................................................................................................