首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

请教delphi怎么像VC那样,通过DLL入口函数获得DLL的hInstance

2012-02-29 
请问delphi如何像VC那样,通过DLL入口函数获得DLL的hInstance ?VC里面可以通过使用DllEntryPoint函数里面的

请问delphi如何像VC那样,通过DLL入口函数获得DLL的hInstance ?
VC里面可以通过使用DllEntryPoint函数里面的参数来获得hInstance实例句柄,  
BOOL   WINAPI   DllEntryPoint(

        HINSTANCE   hinstDLL,//   handle   to   DLL   module  
        DWORD   fdwReason,//   reason   for   calling   function  
        LPVOID   lpvReserved   //   reserved  
      );

但应用在delphi好像不行,   试过  
function   DllEntryPoint(hinstDLL:LongWord;//   handle   to   DLL   module
                                              fdwReason:DWORD;//   reason   for   calling   function
                                              lpvReserved:Pointer   //   reserved
                                              ):Bool;
begin
    MessageBox(0, 'Load ',PChar(IntToHex(hinstDLL,0)),0);
end;

Load对话框是显示了,但是hinstDLL的值却总是为0,   为什么?

请问在delphi中该怎样(利用该函数)获得DLL的实例句柄呢?  
(不用delphi的全局变量hInstance,也不用GetModuleHandle( 'DllName ')来获得).

[解决办法]
DLL的hInstance 其实就是DLL装载到进程地址空间中的基地址,直接调用LoadLibrary函数装载你的DLL文件,其返回值就是DLL的hInstance

热点排行