Delphi把WinMain藏到哪里了?

编程小战 2002-12-20 05:00:30
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)是这样定义的!
但如果我用Delphi写一个纯API程序如下:

program HELLOWIN;

uses Windows,Messages;

var
WndClass:TWndClass;
WndHandle:HWND;
Msg:TMsg;

const
szAppName:PChar='HelloWin';

function WndProc(Handle:HWND;Msg:UINT;wPar:WPARAM;lPar:LPARAM):Cardinal;stdcall;
var
DC:HDC;
PS:PAINTSTRUCT;
RT:TRECT;
begin
Result:=0;
case Msg of
WM_PAINT:
begin
DC:=BeginPaint(WndHandle,PS);
GetClientRect(WndHandle,Rt);
DrawText(DC,'Hello,Windows 2000!',-1,RT,DT_SINGLELINE or DT_CENTER
or DT_VCENTER);
EndPaint(WndHandle,PS);
end;
WM_DESTROY:
PostQuitMessage(0);
else
Result:=DefWindowProc(Handle,Msg,wPar,lPar);
end;
end;

begin
with WndClass do
begin
Style:=CS_HREDRAW or CS_VREDRAW;
lpfnWndProc:=@WndProc;
cbClsExtra:=0;
cbWndExtra:=0;
hInstance:=hInstance;
hIcon:=LoadIcon(0,IDI_APPLICATION);
hCursor:=LoadCursor(0,IDC_ARROW);
hbrBackground:=HBRUSH(GetStockObject(WHITE_BRUSH));
lpszMenuName:=nil;
lpszClassName:=szAppName;
end;
if RegisterClass(WndClass)=0 then
begin
MessageBox(0,'This program requires Windows NT!',szAppName,MB_ICONERROR);
Exit;
end;
WndHandle:=CreateWindow(szAppName,'The Hello Program',WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
0,0,hInstance,nil);
ShowWindow(WndHandle,SW_SHOWNORMAL);
UpdateWindow(WndHandle);
while GetMessage(Msg,0,0,0) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end.

但我怎样访问WinMain的四个参数呢?
1.HINSTANCE hInstance
2.HINSTANCE hPrevInstance
3.LPSTR lpCmdLine
4.int nCmdShow
...全文
16 点赞 收藏 4
写回复
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
goodloop 2002-12-21
同意。在object pascal里是看不到Winmain函数的。整个program的begin就是程序的入口
回复
Eastunfail 2002-12-20
Delphi的入口点执行的代码应该是 begin end.WinMain是C/C++用的
回复
rainsea 2002-12-20
program Project1;

uses
Forms,
Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

看看Application的 实现吧,你会找到答案的。
回复
Billy_Chen28 2002-12-20
参考:
http://expert.csdn.net/Expert/topic/1118/1118675.xml?temp=.2514459
回复
发动态
发帖子
Windows SDK/API
创建于2007-08-02

1145

社区成员

Delphi Windows SDK/API
申请成为版主
社区公告
暂无公告