Delphi开发DLL怎麽實現DllEntry?(30分)

  • 主题发起人 主题发起人 BeginDelphi
  • 开始时间 开始时间
B

BeginDelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
Delphi中,DLL怎麽實現VC中的DllEntry?Help中說,可以用DllProc,但怎麽不行?<br>library SimpleDll;<br>uses Sysutils,math,dialogs;<br>procedure DllMain(Reason: Integer);<br>begin<br>&nbsp; case Reason of<br>&nbsp; &nbsp; 0: ShowMessage('DLL_PROCESS_DETACH');<br>&nbsp; &nbsp; 1: ShowMessage('DLL_PROCESS_ATTACH');<br>&nbsp; &nbsp; 2: ShowMessage('DLL_THREAD_ATTACH');<br>&nbsp; &nbsp; 3: ShowMessage('DLL_THREAD_DETACH');<br>&nbsp; end;<br>end;<br>function Min(const Int1, Int2: Int64): Int64; stdcall; export;<br>begin<br>&nbsp; Result := ifthen(Int1 &gt; int2, int1, int2);<br>end;<br>exports<br>&nbsp; Min;<br>begin<br>&nbsp; DllProc :=@DllMain;<br>&nbsp; DllProcEx:=@DllMain;<br>end.<br><br>還有,Delphi中的API很不全,比如IMM.pas,比起VC的IMM.h少很多東西。
 
可以呀没问题<br>好象要加一句:DllMain(........)
 
你可以自己写一个IMM.PAS呀
 
to jeff168:<br>你說的是什麽意思?DllMain不是系統自動調用的嗎?<br><br>to 张无忌<br>imm.pas我自己已經翻譯了,我只是發發牢騷。我什麽DELPHI中很多API都沒有?
 
to BeginDelphi:<br>你可以到jedi(好象是)去下很多WIN32 API的PAS单元。我手头上有完整的<br>WIN32 API的PAS单元,如果你要我可以发一份给你
 
library DLLEntryLib;<br>uses<br>&nbsp; SysUtils,<br>&nbsp; Windows,<br>&nbsp; Dialogs,<br>&nbsp; Classes;<br><br>procedure DLLEntryPoint(dwReason: DWord);<br>begin<br>&nbsp; case dwReason of<br>&nbsp; &nbsp; DLL_PROCESS_ATTACH: ShowMessage('Attaching to process');<br>&nbsp; &nbsp; DLL_PROCESS_DETACH: ShowMessage('Detaching from process');<br>&nbsp; &nbsp; DLL_THREAD_ATTACH: &nbsp;MessageBeep(0);<br>&nbsp; &nbsp; DLL_THREAD_DETACH: &nbsp;MessageBeep(0);<br>&nbsp; end;<br>end;<br><br>begin<br>&nbsp; { First, assign the procedure to the DLLProc variable }<br>&nbsp; DllProc := @DLLEntryPoint;<br>&nbsp; { Now invoke the procedure to reflect that the DLL is attaching to the<br>&nbsp; &nbsp; process }<br>&nbsp; DLLEntryPoint(DLL_PROCESS_ATTACH);<br>end.
 
to xiao_ping?<br>Thax a lot for you answer.but that's not what I wanna do.<br><br>How can I fire the DLL_Thread_Attach and so on as VC?<br><br>is it a bug of DELPHI?
 
我裝了sp2,一切都正常了。原來是DELPHI的BUG.<br>謝謝大家
 
后退
顶部