⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testdll.dpr

📁 《Delphi开发人员指南》配书原码
💻 DPR
字号:
library TestDLL;

uses
  SysUtils, Dialogs, Windows, WOW32;

const
  DLLStr = 'I am in the 32-bit DLL. The string you sent is: "%s"';

function DLLFunc32(P: PChar; CallBackFunc: DWORD): Integer; stdcall;
const
  MemSize = 256;
var
  Mem16: DWORD;
  Mem32: PChar;
  Hand16: word;
begin
  { Show string P }
  ShowMessage(Format(DLLStr, [P]));
  { Allocate some 16-bit memory }
  Hand16 := WOWGlobalAlloc16(GMem_Share or GMem_Fixed or GMem_ZeroInit,
                             MemSize);
  { Lock the 16-bit memory }
  Mem16 := WOWGlobalLock16(Hand16);
  { Convert 16-bit pointer to 32-bit pointer.  Now they point to the }
  { same place. }
  Mem32 := PChar(WOWGetVDMPointer(Mem16, MemSize, True));
  { Copy string into 32-bit pointer }
  StrPCopy(Mem32, 'I REALLY love DDG!!');
  { Call back into the 16-bit app, passing 16-bit pointer }
  Result := WOWCallback16(CallBackFunc, Mem16);
  { clean up allocated 16-bit memory }
  WOWGlobalUnlockFree16(Mem16);
end;

exports
  DLLFunc32 name 'DLLFunc32' resident;

begin
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -