16位DLL中能否调用32位DLL?(200分)

  • 主题发起人 主题发起人 mahoo
  • 开始时间 开始时间
M

mahoo

Unregistered / Unconfirmed
GUEST, unregistred user!
在98下的打印驱动程序很多是16位的DRV文件,实际上是一个DLL文件(用Delphi1.0编译),我想在里面<br>调用32位的DLL,能行吗?如何调用?<br>
 
好象比较困难,32位调用16位就听说过
 
《Delphi 开发人员指南》里好像有互相调用的例子,记不清了
 
我想应该可以!
 
可以,参考 RxLib 的 RxShell Unit:<br>type<br>&nbsp; TLoadLibrary32 = function (FileName: PChar; Handle, Special: Longint): Longint;<br>&nbsp; TFreeLibrary32 = function (Handle: Longint): Bool;<br>&nbsp; TGetAddress32 = function (Handle: Longint; ProcName: PChar): Pointer;<br>&nbsp; TCallProc32 = function (Msg: Longint; Data: PNotifyIconData; ProcHandle: Pointer;<br>&nbsp; &nbsp; AddressConvert, Params: Longint): Longint;<br>const<br>&nbsp; Shell32: Longint = 0;<br>&nbsp; ProcAddr: Pointer = nil;<br>&nbsp; FreeLib32: TFreeLibrary32 = nil;<br>&nbsp; CallPrc32: TCallProc32 = nil;<br>procedure InitHandles;<br>var<br>&nbsp; Kernel16: THandle;<br>&nbsp; LoadLib32: TLoadLibrary32;<br>&nbsp; GetAddr32: TGetAddress32;<br>begin<br>&nbsp; Kernel16 := GetModuleHandle('kernel');<br>&nbsp; @LoadLib32 := GetProcAddress(Kernel16, 'LoadLibraryEx32W');<br>&nbsp; @FreeLib32 := GetProcAddress(Kernel16, 'FreeLibrary32W');<br>&nbsp; @GetAddr32 := GetProcAddress(Kernel16, 'GetProcAddress32W');<br>&nbsp; @CallPrc32 := GetProcAddress(Kernel16, 'CallProc32W');<br>&nbsp; if (@LoadLib32 &lt;&gt; nil) and (@FreeLib32 &lt;&gt; nil) and (@GetAddr32 &lt;&gt; nil)<br>&nbsp; &nbsp; and (@CallPrc32 &lt;&gt; nil) then<br>&nbsp; begin<br>&nbsp; &nbsp; Shell32 := LoadLib32('shell32', 0, 0);<br>&nbsp; &nbsp; if Shell32 &gt;= HINSTANCE_ERROR then begin<br>&nbsp; &nbsp; &nbsp; ProcAddr := GetAddr32(Shell32, 'Shell_NotifyIcon');<br>&nbsp; &nbsp; &nbsp; if ProcAddr = nil then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; FreeLib32(Shell32);<br>&nbsp; &nbsp; &nbsp; &nbsp; Shell32 := 1;<br>&nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; else AddExitProc(FreeHandles);<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; else Shell32 := 1;<br>&nbsp; end;<br>end;<br><br>这些代码都是 Win16 Subsystem 可以执行的。调用的时候要注意数据大小及对齐方式。<br>顺便问一句:Delphi 5 &amp; C++ Builder 5 Service Pack 各自的 CD-Key 是什么?
 
接受答案了.
 
后退
顶部