梦
梦中过客
Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下,这个窗体是在程序运行中建立,我想让它删除自身并复制自己到系统目录中启动,有窗体的能做到,但这个自己用api建立的窗体,我每回都做失败,请指教,<br>program paswin;<br><br>uses<br> Windows,Messages;<br><br>function WindowProc(Window:Hwnd; AMessage,Wparam,Lparam:Longint):Longint;stdcall;export;<br>begin<br> WindowProc:=0;<br> case AMessage of<br> wm_destroy:<br> begin<br> PostQuitMessage(0);<br> Exit;<br> end;<br> end;<br> WindowProc:=DefWindowProc(Window,AMessage,Wparam,Lparam);<br>end;<br><br>function WinRegister:Boolean;<br>var<br> wincls:TWndClass;<br>begin<br> wincls.style:=cs_hRedraw or cs_vRedraw;<br> wincls.lpfnWndProc:=@WindowProc;<br> wincls.cbClsExtra:=0;<br> wincls.cbWndExtra:=0;<br> wincls.hInstance:=Hinstance;<br> wincls.hIcon:=LoadIcon(0,IDI_APPLICATION);<br> wincls.hCursor:=LoadCursor(0,IDC_Arrow);<br> wincls.hbrBackground:=hBrush(Color_Window);<br> wincls.lpszMenuName:=nil;<br> wincls.lpszClassName:='BLANKWIN';<br> Result:=RegisterClass(Wincls)<>0;<br>end;<br><br>function WinCreate:Hwnd;<br>var<br> hWindow:HWnd;<br>begin<br> hWindow:=CreateWindow('BLANKWIN','A BLANK WINDOW',WS_OVERLAPPEDWINDOW,<br> CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,0,0,Hinstance,nil);<br> if hWindow<>0 then<br> begin<br> ShowWindow(hWindow,Cmdshow);<br> UpdateWindow(hWindow);<br> end;<br> Result:=hWindow;<br>end;<br><br>var<br> AMessage:TMsg;<br> hwindow:HWnd;<br>begin<br> if not WinRegister then Exit;<br> hWindow:=winCreate;<br> if hWindow=0 then Exit;<br> while GetMessage(AMessage,0,0,0) do<br> begin<br> TranslateMessage(AMessage);<br> DispatchMessage(AMessage);<br> end;<br>end.