最小应用程序的问题。请进!

tigerfox 2002-02-19 12:30:24
Program Example;

uses
Sysunits,Windows,Messages;

var
hWin:THandle;
WndClass:TWndClass;
Msg:TMsg;

const
Title='example';
clsName='wincls';

function WinProc(Window:hwnd;Message,wParam,lParam:longint);longint;stdcall;export;
begin
WinProc:=0;
case Message of
WM_DESTROY:
begin
PostQuitMessage(0);
exit;
end;
//....
//....
end;
WinProc:=DefWindowProc(Window,Message,wParam,lParam);
end;

begin
with WndClass do
begin
Style:=WS_OVERLAPPED;
lpfnWndProc:=@WinProc;
cbClsExtra:=0;
cbWndExtra:=0;
hInstance:=hinstance;//1.此处的hinstance,我没有定义是哪来的。
hIcon:=LoadIcon(0,IDI_APPLICATION);
hCursor:=LoadCursor(0,IDC_ARROW);
hbrBackGround:=COLOR_BTNSHADOW;
lpszMenuName:=nil;
lpszClassName:=clsName;
end;
if RegisterClass(WndClass)=0 then
begin
MessageBox(0,'Register fail',MB_OK or MB_ICONINFORMATION);
exit;
end;
hWin:=CreateWindowEx(WS_EX_RTLREADING or WS_EX_APPWINDOW,
clsName,Title,
WS_OVERLAPPEDWINDOW,
integer(CW_USEDEFAULT),integer(CW_USEDEFAULT),
integer(CW_USEDEFAULT),integer(CW_USEDEFAULT),
0,0,hinstance,nil);
if hWin<>0 then
begin
ShowWindow(hWin,SW_SHOW);
UpdateWindow(hWin);
end;
while GetMessage(Msg,0,0,0) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
halt(Msg.wParam)
end.

问题:
 1,1处的hinstance是哪来的。我跟踪过这个变量有值。
 2,窗口函数中的那个export关键字是什么意思.

此外,还是一个其它问题:如何动态和静态生成GUID,我知道在delphi中按ctrl+shift+G可以生成GUID ,还有其它方法吗?有生成这个GUID的程序吗。
...全文
54 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
tigerfox 2002-02-19
  • 打赏
  • 举报
回复
没人知道吗?
li_zhifu 2002-02-19
  • 打赏
  • 举报
回复
SysInit.pas中
HInstance: LongWord; { Handle of this instance }
delphiforever 2002-02-19
  • 打赏
  • 举报
回复
SDK下,hInstance是WinMain的一个参数
export好像是为了使用其它Dll或包中的函数,或输出为其它Dll或包使用
xzgyb 2002-02-19
  • 打赏
  • 举报
回复
hInstance好蟓是SysInit下的把

ActiveX下
CoCreateGUID
xzgyb 2002-02-19
  • 打赏
  • 举报
回复
The directives near, far, and export refer to calling conventions in 16-bit Windows programming. They have no effect in 32-bit applications and are maintained for backward compatibility only.

先USES上ActiveX
procedure TForm1.Button1Click(Sender: TObject);
var
G: TGUID;
p: PWideChar;
begin
if (CoCreateGUID(G) = S_OK) and (StringFromCLSID(G, p) = S_OK) then
ShowMessage(p);
end;


sunhuiNO1 2002-02-19
  • 打赏
  • 举报
回复
是一个全局变量拉,
不信你在DELPHI的VCL状态下用,不用申明的拉,
tigerfox 2002-02-19
  • 打赏
  • 举报
回复
thank you!

5,931

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧