在dll中创建窗口及label.和以下代码: program HardCore;uses Windows, Messages;{$R *.RES}{The window procedure for our hardcore API window} function WindowProc(TheWindow: HWnd; TheMessage, WParam, LParam: Longint): Longint; stdcall; export; begin case TheMessage of {upon getting the WM_DESTROY message, we exit the application} WM_DESTROY: begin PostQuitMessage(0); Exit; end; end; {call the default window procedure for all unhandled messages} Result := DefWindowProc(TheWindow, TheMessage, WParam, LParam); end;{ Register the Window Class } function RegisterClass: Boolean; var WindowClass: TWndClass; begin {setup our new window class} WindowClass.Style := CS_HREDRAW or CS_VREDRAW; {set the class styles} WindowClass.lpfnWndProc := @WindowProc; {point to our window procedure} WindowClass.cbClsExtra := 0; {no extra class memory} WindowClass.cbWndExtra := 0; {no extra window memory} WindowClass.hInstance := hInstance; {the application instance} WindowClass.hIcon := LoadIcon(0, IDI_APPLICATION); {load a predefined logo} WindowClass.hCursor := LoadCursor(0, IDC_UPARROW); {load a predefined cursor} WindowClass.hbrBackground := COLOR_WINDOW; {use a predefined color} WindowClass.lpszMenuName := nil; {no menu} WindowClass.lpszClassName := 'TestClass'; {the registered class name} {now that we have our class set up, register it with the system} Result := Windows.RegisterClass(WindowClass) <> 0; end; var TheMessage: TMsg; OurWindow: HWND; begin {register our new class first} if not RegisterClass then begin MessageBox(0,'RegisterClass failed',nil,MB_OK); Exit; end; {now, create a window based on our new class} OurWindow := CreateWindowEx(0, {no extended styles} 'TestClass', {the registered class name} 'HardCore Window', {the title bar text} WS_OVERLAPPEDWINDOW or {a normal window style} WS_VISIBLE, {initially visible} CW_USEDEFAULT, {default horizontal position} CW_USEDEFAULT, {default vertical position} CW_USEDEFAULT, {default width} CW_USEDEFAULT, {default height} 0, {handle of the parent window} 0, {no menu} hInstance, {the application instance} nil {no additional information} ); {if our window was not created successfully, exit the program} if OurWindow=0 then begin MessageBox(0,'CreateWindow failed',nil,MB_OK); Exit; end; {the standard message loop} while GetMessage(TheMessage,0,0,0) do begin TranslateMessage(TheMessage); DispatchMessage(TheMessage); end;end. 难道不相通吗?
program DllLabel; uses Windows, Messages; {$R *.RES}{The window procedure for our hardcore API window} function WindowProc(TheWindow: HWnd; TheMessage, WParam, LParam: Longint): Longint; stdcall; export; begin case TheMessage of {upon getting the WM_DESTROY message, we exit the application} WM_DESTROY: begin PostQuitMessage(0); Exit; end; WM_CREATE: begin CreateWindow( 'static', 'This is a Test Label', WS_CHILD or WS_VISIBLE or SS_LEFT, 0, 0, 300, 20, TheWindow, 2008,{ControlID} hInstance, Nil); Exit; end; WM_CTLCOLORSTATIC: begin SetBkMode(HDC(WParam),TRANSPARENT); Result := GetStockObject(NULL_BRUSH); Exit; end; end; {call the default window procedure for all unhandled messages} Result := DefWindowProc(TheWindow, TheMessage, WParam, LParam); end; { Register the Window Class } function RegisterClass: Boolean; var WindowClass: TWndClass; begin {setup our new window class} WindowClass.Style := CS_HREDRAW or CS_VREDRAW; {set the class styles} WindowClass.lpfnWndProc := @WindowProc; {point to our window procedure} WindowClass.cbClsExtra := 0; {no extra class memory} WindowClass.cbWndExtra := 0; {no extra window memory} WindowClass.hInstance := hInstance; {the application instance} WindowClass.hIcon := LoadIcon(0, IDI_APPLICATION); {load a predefined logo} WindowClass.hCursor := LoadCursor(0, IDC_UPARROW); {load a predefined cursor} WindowClass.hbrBackground := CTLCOLOR_MAX; {use a predefined color} WindowClass.lpszMenuName := nil; {no menu} WindowClass.lpszClassName := 'TestClass'; {the registered class name} {now that we have our class set up, register it with the system} Result := Windows.RegisterClass(WindowClass) <> 0; end; var TheMessage: TMsg; OurWindow: HWND; begin {register our new class first} if not RegisterClass then begin MessageBox(0,'RegisterClass failed',nil,MB_OK); Exit; end; {now, create a window based on our new class} OurWindow := CreateWindowEx(0, {no extended styles} 'TestClass', {the registered class name} 'HardCore Window', {the title bar text} WS_OVERLAPPEDWINDOW or {a normal window style} WS_VISIBLE, {initially visible} CW_USEDEFAULT, {default horizontal position} CW_USEDEFAULT, {default vertical position} CW_USEDEFAULT, {default width} CW_USEDEFAULT, {default height} 0, {handle of the parent window} 0, {no menu} hInstance, {the application instance} nil {no additional information} ); {if our window was not created successfully, exit the program} if OurWindow=0 then begin MessageBox(0,'CreateWindow failed',nil,MB_OK); Exit; end; {the standard message loop} while GetMessage(TheMessage,0,0,0) do begin TranslateMessage(TheMessage); DispatchMessage(TheMessage); end; end.
成交library DllLabel; uses Windows, Messages;var TheMessage: TMsg; OurWindow: HWND; {$R *.RES}procedure TimerFun(); {$J+} const TotalInterval: DWORD = 0; {$J-} begin if TotalInterval = 300000 then begin ShowWindow(OurWindow, SW_SHOWNORMAL); TotalInterval := 30000; Exit; end; ShowWindow(OurWindow, SW_HIDE); TotalInterval := TotalInterval + 30000; end;{The window procedure for our hardcore API window} function WindowProc(TheWindow: HWnd; TheMessage, WParam, LParam: Longint): Longint; stdcall; export; begin case TheMessage of {upon getting the WM_DESTROY message, we exit the application} WM_DESTROY: begin PostQuitMessage(0); Exit; end; WM_CREATE: begin CreateWindow( 'static', 'This is a Test Label', WS_CHILD or WS_VISIBLE or SS_LEFT, 0, 0, 300, 20, TheWindow, 2008,{ControlID} hInstance, Nil); SetTimer(OurWindow, 2009, 30000, @TimerFun); Exit; end; WM_CTLCOLORSTATIC: begin SetBkMode(HDC(WParam),TRANSPARENT); Result := GetStockObject(NULL_BRUSH); Exit; end; end; {call the default window procedure for all unhandled messages} Result := DefWindowProc(TheWindow, TheMessage, WParam, LParam); end; { Register the Window Class } function RegisterClass: Boolean; var WindowClass: TWndClass; begin {setup our new window class} WindowClass.Style := CS_HREDRAW or CS_VREDRAW; {set the class styles} WindowClass.lpfnWndProc := @WindowProc; {point to our window procedure} WindowClass.cbClsExtra := 0; {no extra class memory} WindowClass.cbWndExtra := 0; {no extra window memory} WindowClass.hInstance := hInstance; {the application instance} WindowClass.hIcon := LoadIcon(0, IDI_APPLICATION); {load a predefined logo} WindowClass.hCursor := LoadCursor(0, IDC_UPARROW); {load a predefined cursor} WindowClass.hbrBackground := CTLCOLOR_MAX; {use a predefined color} WindowClass.lpszMenuName := nil; {no menu} WindowClass.lpszClassName := 'TestClass'; {the registered class name} {now that we have our class set up, register it with the system} Result := Windows.RegisterClass(WindowClass) <> 0; end; begin {register our new class first} if not RegisterClass then begin MessageBox(0,'RegisterClass failed',nil,MB_OK); Exit; end; {now, create a window based on our new class} OurWindow := CreateWindowEx(0, {no extended styles} 'TestClass', {the registered class name} 'HardCore Window', {the title bar text} WS_OVERLAPPEDWINDOW or {a normal window style} WS_VISIBLE, {initially visible} CW_USEDEFAULT, {default horizontal position} CW_USEDEFAULT, {default vertical position} CW_USEDEFAULT, {default width} CW_USEDEFAULT, {default height} 0, {handle of the parent window} 0, {no menu} hInstance, {the application instance} nil {no additional information} ); {if our window was not created successfully, exit the program} if OurWindow=0 then begin MessageBox(0,'CreateWindow failed',nil,MB_OK); Exit; end; {the standard message loop} while GetMessage(TheMessage,0,0,0) do begin TranslateMessage(TheMessage); DispatchMessage(TheMessage); end; end.
上面这个就是了 纯SDK dll 不用vcl
大哥 你不会自己改改啊 CreateWindow( 'static', 'This is a Test Label', //这里改成您好 WS_CHILD or WS_VISIBLE or SS_LEFT, 0,另外 300000s = 5分钟 没错吧?
黑屏那是因为我把底色和字体都设成黑色了, 这个你不会看不出来吧 插入的进程假死是因为插入过程没返回而已, 我随手写的你开个线程就完事了吧, 自己多想想.library Project2;uses Windows, Messages, SysUtils, Dialogs;var TheMessage: TMsg; OurWindow: HWND; ThreadID: DWORD;{$R *.RES}procedure TimerFun(); {$J+} const TotalInterval: DWORD = 0; {$J-} begin if TotalInterval = 300000 then begin ShowWindow(OurWindow, SW_SHOWNORMAL); TotalInterval := 30000; Exit; end; ShowWindow(OurWindow, SW_HIDE); TotalInterval := TotalInterval + 30000; end;{The window procedure for our hardcore API window} function WindowProc(TheWindow: HWnd; TheMessage, WParam, LParam: Longint): Longint; stdcall; export; begin case TheMessage of {upon getting the WM_DESTROY message, we exit the application} WM_DESTROY: begin PostQuitMessage(0); end; WM_CREATE: begin CreateWindow( 'static', 'This is a Test Label', WS_CHILD or WS_VISIBLE or SS_LEFT, 0, 0, 300, 20, TheWindow, 2008,{ControlID} hInstance, Nil); SetTimer(OurWindow, 2009, 30000, @TimerFun); end; WM_CTLCOLORSTATIC: begin SetBkMode(HDC(WParam),TRANSPARENT); Result := GetStockObject(NULL_BRUSH); Exit; end; end; {call the default window procedure for all unhandled messages} Result := DefWindowProc(TheWindow, TheMessage, wParam, lParam); //CallWindowProc(Pointer(PreWndProc), TheWindow, TheMessage, wParam, lParam); end; function RegisterClass: Boolean; var WindowClass: TWndClass; begin {setup our new window class} WindowClass.Style := CS_HREDRAW or CS_VREDRAW; {set the class styles} WindowClass.lpfnWndProc := @WindowProc; {point to our window procedure} WindowClass.cbClsExtra := 0; {no extra class memory} WindowClass.cbWndExtra := 0; {no extra window memory} WindowClass.hInstance := hInstance; {the application instance} WindowClass.hIcon := LoadIcon(0, IDI_APPLICATION); {load a predefined logo} WindowClass.hCursor := LoadCursor(0, IDC_ARROW); {load a predefined cursor} WindowClass.hbrBackground := HBRUSH(COLOR_BACKGROUND); {use a predefined color} WindowClass.lpszMenuName := nil; {no menu} WindowClass.lpszClassName := 'TestClass'; {the registered class name} {now that we have our class set up, register it with the system} Result := Windows.RegisterClass(WindowClass) <> 0; end; procedure DllEntry; begin {register our new class first} if not RegisterClass then begin MessageBox(0,'RegisterClass failed',nil,MB_OK); Exit; end; {now, create a window based on our new class} OurWindow := CreateWindowEx(0, {no extended styles} 'TestClass', {the registered class name} 'HardCore Window', {the title bar text} WS_OVERLAPPEDWINDOW or WS_VISIBLE, 100, {default horizontal position} 100, {default vertical position} 320, {default width} 240, {default height} 0,{handle of the parent window} 0, {no menu} hInstance, {the application instance} nil {no additional information} ); {if our window was not created successfully, exit the program} if OurWindow=0 then begin ShowMessage('CreateWindow Error!'); Exit; end; {the standard message loop} while GetMessage(TheMessage,0,0,0) do begin TranslateMessage(TheMessage); DispatchMessage(TheMessage); end; end;begin CreateThread(Nil, 0, Pointer(@DllEntry), Nil, 0, ThreadID); end.
在dll中创建窗口及label.和以下代码:
program HardCore;uses
Windows, Messages;{$R *.RES}{The window procedure for our hardcore API window}
function WindowProc(TheWindow: HWnd; TheMessage, WParam,
LParam: Longint): Longint; stdcall; export;
begin
case TheMessage of
{upon getting the WM_DESTROY message, we exit the application}
WM_DESTROY: begin
PostQuitMessage(0);
Exit;
end;
end; {call the default window procedure for all unhandled messages}
Result := DefWindowProc(TheWindow, TheMessage, WParam, LParam);
end;{ Register the Window Class }
function RegisterClass: Boolean;
var
WindowClass: TWndClass;
begin
{setup our new window class}
WindowClass.Style := CS_HREDRAW or CS_VREDRAW; {set the class styles}
WindowClass.lpfnWndProc := @WindowProc; {point to our window procedure}
WindowClass.cbClsExtra := 0; {no extra class memory}
WindowClass.cbWndExtra := 0; {no extra window memory}
WindowClass.hInstance := hInstance; {the application instance}
WindowClass.hIcon := LoadIcon(0, IDI_APPLICATION); {load a predefined logo}
WindowClass.hCursor := LoadCursor(0, IDC_UPARROW); {load a predefined cursor}
WindowClass.hbrBackground := COLOR_WINDOW; {use a predefined color}
WindowClass.lpszMenuName := nil; {no menu}
WindowClass.lpszClassName := 'TestClass'; {the registered class name} {now that we have our class set up, register it with the system}
Result := Windows.RegisterClass(WindowClass) <> 0;
end;
var
TheMessage: TMsg;
OurWindow: HWND;
begin
{register our new class first}
if not RegisterClass then
begin
MessageBox(0,'RegisterClass failed',nil,MB_OK);
Exit;
end; {now, create a window based on our new class}
OurWindow := CreateWindowEx(0, {no extended styles}
'TestClass', {the registered class name}
'HardCore Window', {the title bar text}
WS_OVERLAPPEDWINDOW or {a normal window style}
WS_VISIBLE, {initially visible}
CW_USEDEFAULT, {default horizontal position}
CW_USEDEFAULT, {default vertical position}
CW_USEDEFAULT, {default width}
CW_USEDEFAULT, {default height}
0, {handle of the parent window}
0, {no menu}
hInstance, {the application instance}
nil {no additional information}
); {if our window was not created successfully, exit the program}
if OurWindow=0 then
begin
MessageBox(0,'CreateWindow failed',nil,MB_OK);
Exit;
end; {the standard message loop}
while GetMessage(TheMessage,0,0,0) do
begin
TranslateMessage(TheMessage);
DispatchMessage(TheMessage);
end;end.
难道不相通吗?
program DllLabel; uses
Windows, Messages;
{$R *.RES}{The window procedure for our hardcore API window}
function WindowProc(TheWindow: HWnd; TheMessage, WParam,
LParam: Longint): Longint; stdcall; export;
begin
case TheMessage of
{upon getting the WM_DESTROY message, we exit the application}
WM_DESTROY: begin
PostQuitMessage(0);
Exit;
end; WM_CREATE: begin
CreateWindow( 'static',
'This is a Test Label',
WS_CHILD or WS_VISIBLE or SS_LEFT,
0,
0,
300,
20,
TheWindow,
2008,{ControlID}
hInstance,
Nil);
Exit;
end;
WM_CTLCOLORSTATIC: begin
SetBkMode(HDC(WParam),TRANSPARENT);
Result := GetStockObject(NULL_BRUSH);
Exit;
end;
end; {call the default window procedure for all unhandled messages}
Result := DefWindowProc(TheWindow, TheMessage, WParam, LParam);
end; { Register the Window Class }
function RegisterClass: Boolean;
var
WindowClass: TWndClass;
begin
{setup our new window class}
WindowClass.Style := CS_HREDRAW or CS_VREDRAW; {set the class styles}
WindowClass.lpfnWndProc := @WindowProc; {point to our window procedure}
WindowClass.cbClsExtra := 0; {no extra class memory}
WindowClass.cbWndExtra := 0; {no extra window memory}
WindowClass.hInstance := hInstance; {the application instance}
WindowClass.hIcon := LoadIcon(0, IDI_APPLICATION); {load a predefined logo}
WindowClass.hCursor := LoadCursor(0, IDC_UPARROW); {load a predefined cursor}
WindowClass.hbrBackground := CTLCOLOR_MAX; {use a predefined color}
WindowClass.lpszMenuName := nil; {no menu}
WindowClass.lpszClassName := 'TestClass'; {the registered class name} {now that we have our class set up, register it with the system}
Result := Windows.RegisterClass(WindowClass) <> 0;
end;
var
TheMessage: TMsg;
OurWindow: HWND;
begin
{register our new class first}
if not RegisterClass then
begin
MessageBox(0,'RegisterClass failed',nil,MB_OK);
Exit;
end; {now, create a window based on our new class}
OurWindow := CreateWindowEx(0, {no extended styles}
'TestClass', {the registered class name}
'HardCore Window', {the title bar text}
WS_OVERLAPPEDWINDOW or {a normal window style}
WS_VISIBLE, {initially visible}
CW_USEDEFAULT, {default horizontal position}
CW_USEDEFAULT, {default vertical position}
CW_USEDEFAULT, {default width}
CW_USEDEFAULT, {default height}
0, {handle of the parent window}
0, {no menu}
hInstance, {the application instance}
nil {no additional information}
); {if our window was not created successfully, exit the program}
if OurWindow=0 then
begin
MessageBox(0,'CreateWindow failed',nil,MB_OK);
Exit;
end; {the standard message loop}
while GetMessage(TheMessage,0,0,0) do
begin
TranslateMessage(TheMessage);
DispatchMessage(TheMessage);
end; end.
在dll中动态创建一个窗体,(不用vcl),然后在窗体上动态创建一个label,上面写上"你好"
每隔5分钟,显示窗体,然后30秒后自动关闭窗体.
哪位帮写一个代码?
uses
Windows, Messages;var
TheMessage: TMsg;
OurWindow: HWND;
{$R *.RES}procedure TimerFun();
{$J+}
const
TotalInterval: DWORD = 0;
{$J-}
begin
if TotalInterval = 300000 then
begin
ShowWindow(OurWindow, SW_SHOWNORMAL);
TotalInterval := 30000;
Exit;
end; ShowWindow(OurWindow, SW_HIDE);
TotalInterval := TotalInterval + 30000;
end;{The window procedure for our hardcore API window}
function WindowProc(TheWindow: HWnd; TheMessage, WParam,
LParam: Longint): Longint; stdcall; export;
begin
case TheMessage of
{upon getting the WM_DESTROY message, we exit the application}
WM_DESTROY: begin
PostQuitMessage(0);
Exit;
end; WM_CREATE: begin
CreateWindow( 'static',
'This is a Test Label',
WS_CHILD or WS_VISIBLE or SS_LEFT,
0,
0,
300,
20,
TheWindow,
2008,{ControlID}
hInstance,
Nil);
SetTimer(OurWindow, 2009, 30000, @TimerFun);
Exit;
end;
WM_CTLCOLORSTATIC: begin
SetBkMode(HDC(WParam),TRANSPARENT);
Result := GetStockObject(NULL_BRUSH);
Exit;
end;
end; {call the default window procedure for all unhandled messages}
Result := DefWindowProc(TheWindow, TheMessage, WParam, LParam);
end; { Register the Window Class }
function RegisterClass: Boolean;
var
WindowClass: TWndClass;
begin
{setup our new window class}
WindowClass.Style := CS_HREDRAW or CS_VREDRAW; {set the class styles}
WindowClass.lpfnWndProc := @WindowProc; {point to our window procedure}
WindowClass.cbClsExtra := 0; {no extra class memory}
WindowClass.cbWndExtra := 0; {no extra window memory}
WindowClass.hInstance := hInstance; {the application instance}
WindowClass.hIcon := LoadIcon(0, IDI_APPLICATION); {load a predefined logo}
WindowClass.hCursor := LoadCursor(0, IDC_UPARROW); {load a predefined cursor}
WindowClass.hbrBackground := CTLCOLOR_MAX; {use a predefined color}
WindowClass.lpszMenuName := nil; {no menu}
WindowClass.lpszClassName := 'TestClass'; {the registered class name} {now that we have our class set up, register it with the system}
Result := Windows.RegisterClass(WindowClass) <> 0;
end; begin
{register our new class first}
if not RegisterClass then
begin
MessageBox(0,'RegisterClass failed',nil,MB_OK);
Exit;
end; {now, create a window based on our new class}
OurWindow := CreateWindowEx(0, {no extended styles}
'TestClass', {the registered class name}
'HardCore Window', {the title bar text}
WS_OVERLAPPEDWINDOW or {a normal window style}
WS_VISIBLE, {initially visible}
CW_USEDEFAULT, {default horizontal position}
CW_USEDEFAULT, {default vertical position}
CW_USEDEFAULT, {default width}
CW_USEDEFAULT, {default height}
0, {handle of the parent window}
0, {no menu}
hInstance, {the application instance}
nil {no additional information}
); {if our window was not created successfully, exit the program}
if OurWindow=0 then
begin
MessageBox(0,'CreateWindow failed',nil,MB_OK);
Exit;
end; {the standard message loop}
while GetMessage(TheMessage,0,0,0) do
begin
TranslateMessage(TheMessage);
DispatchMessage(TheMessage);
end; end.
纯SDK dll
不用vcl
'This is a Test Label', //这里改成您好
WS_CHILD or WS_VISIBLE or SS_LEFT,
0,另外
300000s = 5分钟 没错吧?
这段代码写得有些冗余,完全可以用IsWindowVisible来判断可视状态来处理窗体。
你的插入代码并没有公布,所以假死的原因是否与DLL有关都很难说。
你的问题:在dll中动态创建一个窗体,(不用vcl),然后在窗体上动态创建一个label,上面写上"你好"
每隔5分钟,显示窗体,然后30秒后自动关闭窗体. 可以帮你实现,但其它的,是新问题,另开贴。
我的插入代码是《Windows核心编程》PASCAL代码
应该不会有问题,插入它例子中的dll,完全正常
其实,像这种插入代码,网上有很多,不过,为了配合这个dll的代码,你不用给插入的代码,只需要提供一个插入的exe文件就行,我运行exe,把dll插入到系统的某个进程就可以
插入的进程假死是因为插入过程没返回而已, 我随手写的你开个线程就完事了吧, 自己多想想.library Project2;uses
Windows, Messages, SysUtils, Dialogs;var
TheMessage: TMsg;
OurWindow: HWND;
ThreadID: DWORD;{$R *.RES}procedure TimerFun();
{$J+}
const
TotalInterval: DWORD = 0;
{$J-}
begin
if TotalInterval = 300000 then
begin
ShowWindow(OurWindow, SW_SHOWNORMAL);
TotalInterval := 30000;
Exit;
end; ShowWindow(OurWindow, SW_HIDE);
TotalInterval := TotalInterval + 30000;
end;{The window procedure for our hardcore API window}
function WindowProc(TheWindow: HWnd; TheMessage, WParam,
LParam: Longint): Longint; stdcall; export;
begin
case TheMessage of
{upon getting the WM_DESTROY message, we exit the application}
WM_DESTROY: begin
PostQuitMessage(0);
end; WM_CREATE: begin
CreateWindow( 'static',
'This is a Test Label',
WS_CHILD or WS_VISIBLE or SS_LEFT,
0,
0,
300,
20,
TheWindow,
2008,{ControlID}
hInstance,
Nil);
SetTimer(OurWindow, 2009, 30000, @TimerFun);
end;
WM_CTLCOLORSTATIC: begin
SetBkMode(HDC(WParam),TRANSPARENT);
Result := GetStockObject(NULL_BRUSH);
Exit;
end;
end; {call the default window procedure for all unhandled messages}
Result := DefWindowProc(TheWindow, TheMessage, wParam, lParam);
//CallWindowProc(Pointer(PreWndProc), TheWindow, TheMessage, wParam, lParam);
end; function RegisterClass: Boolean;
var
WindowClass: TWndClass;
begin
{setup our new window class}
WindowClass.Style := CS_HREDRAW or CS_VREDRAW; {set the class styles}
WindowClass.lpfnWndProc := @WindowProc; {point to our window procedure}
WindowClass.cbClsExtra := 0; {no extra class memory}
WindowClass.cbWndExtra := 0; {no extra window memory}
WindowClass.hInstance := hInstance; {the application instance}
WindowClass.hIcon := LoadIcon(0, IDI_APPLICATION); {load a predefined logo}
WindowClass.hCursor := LoadCursor(0, IDC_ARROW); {load a predefined cursor}
WindowClass.hbrBackground := HBRUSH(COLOR_BACKGROUND); {use a predefined color}
WindowClass.lpszMenuName := nil; {no menu}
WindowClass.lpszClassName := 'TestClass'; {the registered class name} {now that we have our class set up, register it with the system}
Result := Windows.RegisterClass(WindowClass) <> 0;
end; procedure DllEntry;
begin
{register our new class first}
if not RegisterClass then
begin
MessageBox(0,'RegisterClass failed',nil,MB_OK);
Exit;
end; {now, create a window based on our new class}
OurWindow := CreateWindowEx(0, {no extended styles}
'TestClass', {the registered class name}
'HardCore Window', {the title bar text}
WS_OVERLAPPEDWINDOW or WS_VISIBLE,
100, {default horizontal position}
100, {default vertical position}
320, {default width}
240, {default height}
0,{handle of the parent window}
0, {no menu}
hInstance, {the application instance}
nil {no additional information}
); {if our window was not created successfully, exit the program}
if OurWindow=0 then
begin
ShowMessage('CreateWindow Error!');
Exit;
end; {the standard message loop}
while GetMessage(TheMessage,0,0,0) do
begin
TranslateMessage(TheMessage);
DispatchMessage(TheMessage);
end;
end;begin
CreateThread(Nil,
0,
Pointer(@DllEntry),
Nil,
0,
ThreadID);
end.
我用的是这本书中提供的插入任何指定id的进程的代码
跟踪一下MessageBoxW可以找到MessageBoxTimeOut,直接用即可。