- 1
- 0
- 约1.92千字
- 约 5页
- 2023-09-03 发布于浙江
- 举报
delphi做的dll消息循环方便其它脚本工具调用广海游戏
delphi嵌汇编是非常好的容易的
library delphi_api_dll;
uses
Windows, Messages, Shellapi, Dialogs;
//{$R *.res}
const
wM_User = $400;
function Msg(wParam, lParam: Cardinal): Cardinal; stdcall begin
ShowMessage(char(wParam) + char(lParam));
end;
function WinProc(hWnd: THandle; nMsg: UINT;
wParam, lParam: Cardinal): Cardinal; export; stdcall; begin
case nMsg of
wM_User + 401: //对话消息
Msg(wParam, lParam);
end;
result := DefWindowProc(hWnd, nMsg, wParam, lParam); end; //消息回调函数
procedure WinMain;
var
hWnd: THandle;
Msg: TMsg;
WndClassEx: TWndClassEx; //注册窗口类
begin
WndClassEx.cbSize := SizeOf(TWndClassEx);
WndClassEx.lpszClassName := api_dll;
WndClassEx.style := cs_VRedraw or cs_HRedraw;
WndClassEx.hInstance := Hinstance;
WndClassEx.lpfnWndProc := @WinProc;
WndClassEx.cbClsExtra := 0;
WndClassEx.cbWndExtra := 0;
WndClassEx.hIcon := LoadIcon(Hinstance,
Pchar(MAINICON));
WndClassEx.hIconSm := LoadIcon(Hinstance,
Pchar(MAINICON));
WndClassEx.hCursor := LoadCursor(0, idc_Arrow);
WndClassEx.hbrBackground :=
GetStockObject(gray_Brush);
WndClassEx.lpszMenuName := nil;
if RegisterClassEx(WndClassEx) 0 then
begin
hWnd := CreateWindowEx(WS_EX_TOPMOST or WS_EX_ACCEPTFILES,
WndClassEx.lpszClassName,
api_dll, ws_OverlappedWindow,
0, 0, 0, 0, 0, 0,
Hinstance, nil); //创建窗口HeroXs
if hWnd 0 then
begin
ShowWindow(hWnd, SW_HIDE); //隐藏DLL窗口
//ShowWindow(hWnd,
SW_ShowNormal);//显示DLL窗口
while GetMessage(Msg, hWnd, 0, 0) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;
end;
end; //DLL消息循环窗口
procedure DllMain(hModule: HMODULE; Reason: Integer; lpReserved: Pointer);
var
TheThread: DWORD; //返回线程ID
begin
case Reason of
DLL_PROCESS_ATTACH:
CreateThread(nil, 0, @WinMain, nil, 0, TheThread);
end;
end; //DLL进入时创建窗口线程
exports
Msg; //导出
begin
DLLProc := @DllMain;
DllMain(hInstance, DLL_PROCESS_ATTACH, nil); end.
原创力文档

文档评论(0)