..
解决方案 »
- 我开发了一个MODEM拨号程序
- delphi 的使用raize控件补丁的问题???
- 江湖救急!为什么本来得一次,现在变成两次了????????
- 如何才能打开加密的paradox数据库,我忘记口令了,请高手给指点了。
- 关于SQL server 的大问题,请大家救救命!!!!
- 如何使用游标读写数据库查询结果???????
- How to study Delphi for a new peoper
- 返朴归真,这个sql语言怎么不对?
- 求ping程序的源代码。。。!
- 很简单:) delphi补丁 D5EntUpdate 的key.
- 关于 TFileStream.Create()读文件流的问题
- 如何设置num,scroll,capslock的状态
晚上回去我发给你。
run后是生成一个30几K的exe,如果删除uses SysUtils;
run生产只有几k的exe
我的email:[email protected]
我还要运行 winexec()程序。
Windows,
Messages;var
WinClass: TWndClassA;
Inst, Handle, Button1, Label1, Edit1: Integer;
Msg: TMsg;
hFont: Integer;{ Checks if typed password is 'Amigreen' and shows Message }
procedure CheckPassword;
var
Textlength: Integer;
Text: PChar;
begin
TextLength := GetWindowTextLength(Edit1);
if TextLength = 8 then
begin
GetMem(Text, TextLength + 1);
GetWindowText(Edit1, Text, TextLength + 1);
if Text = 'Amigreen' then
begin
MessageBoxA(Handle, 'Password is correct.', 'Password check', MB_OK);
FreeMem(Text, TextLength + 1);
Exit;
end;
end;
MessageBoxA(Handle, 'Password is incorrect.', 'Password check', MB_OK);
end;{ Custom WindowProc function }
function WindowProc(hWnd, uMsg, wParam, lParam: Integer): Integer; stdcall;
begin
Result := DefWindowProc(hWnd, uMsg, wParam, lParam);
{ Checks for messages }
if (lParam = Button1) and (uMsg = WM_COMMAND) then
CheckPassword;
if uMsg = WM_DESTROY then
Halt;
end;begin
{ ** Register Custom WndClass ** }
Inst := hInstance;
with WinClass do
begin
style := CS_CLASSDC or CS_PARENTDC;
lpfnWndProc := @WindowProc;
hInstance := Inst;
hbrBackground := color_btnface + 1;
lpszClassname := 'AG_TESTWINDOW';
hCursor := LoadCursor(0, IDC_ARROW);
end; { with }
RegisterClass(WinClass); { ** Create Main Window ** }
Handle := CreateWindowEx(WS_EX_WINDOWEDGE, 'AG_TESTWINDOW', 'Amigreen TestWindow 1.00',
WS_VISIBLE or WS_SIZEBOX or WS_CAPTION or WS_SYSMENU,
363, 278, 305, 65, 0, 0, Inst, nil);
{ ** Create a button ** }
Button1 := CreateWindow('Button', 'OK', WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or BS_TEXT,
216, 8, 75, 25, handle, 0, Inst, nil);
{ ** Create a label (static) ** }
Label1 := Createwindow('Static', '', WS_VISIBLE or WS_CHILD or SS_LEFT,
8, 12, 76, 13, Handle, 0, Inst, nil); { ** Create an edit field ** }
Edit1 := CreateWindowEx(WS_EX_CLIENTEDGE, 'Edit', '', WS_CHILD or WS_VISIBLE or
WS_BORDER or ES_PASSWORD, 88, 8, 121, 21, Handle, 0, Inst, nil); { ** Create Font Handle ** }
hFont := CreateFont(-11, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH or FF_DONTCARE, 'MS Sans Serif'); { Change fonts }
if hFont <> 0 then
begin
SendMessage(Button1, WM_SETFONT, hFont, 0);
SendMessage(Label1, WM_SETFONT, hFont, 0);
SendMessage(Edit1, WM_SETFONT, hFont, 0);
end;
{ Change label (static) text }
SetWindowText(Label1, 'Enter password:');
{ Set the focus to the edit control }
SetFocus(Edit1); UpdateWindow(Handle); { ** Message Loop ** }
while(GetMessage(Msg, Handle, 0, 0)) do
begin
TranslateMessage(msg);
DispatchMessage(msg);
end; { with }
end.
uses
Windows,
Messages;
var
Msg:TMsg;
wc:TWndClass; //RegisterClass()所需要的参数
hWnd:THandle; //主窗体的句柄
const
ClassName='MainWClass';
OutText='我爱你。';
Function MainWndProc(Handle:THandle;MsgID:UINT;wParam,lParam:Integer):LRESULT;stdcall;
var
pDC:HDC;
lpRect:TRECT;
begin
Result:=1;
case MsgID of
WM_CLOSE:
begin //关闭窗体所产生的消息
if MessageBox(Handle,'要关闭这个程序吗?','程序示例',MB_ICONQUESTION or MB_YESNO)=IDYES then
DestroyWindow(hWnd)
else
Result:=0;
Exit;
end;
WM_DESTROY: //DestroyWindow()所产生的消息
begin
PostQuitMessage(0);
end;
WM_PAINT:
begin
pDC:=GetDC(hWnd);
GetClientRect(hWnd,lpRect);
DrawText(pDC,OutText,8,lpRect,DT_SINGLELINE or DT_CENTER or DT_VCENTER);
ReleaseDC(hWnd,pDC);
end;
end;
//剩下的消息交给Windows预设的处理函数就可以了,比如画窗体的WM_NCPAINT消息等等
Result:=DefWindowProc(Handle,MsgID,wParam,lParam);
end;
//初始化,注册窗口类
Function InitApplication(hInstance:THANDLE):Boolean;
begin
//首先使用RegisterClass()注册窗体类,这可不是Delphi数据类型中的类哦
wc.style:=CS_HREDRAW OR CS_VREDRAW;
wc.lpfnWndProc:=@MainWndProc; //消息处理函数的地址
wc.hInstance:=hInstance; //程序的句柄,同时也是基地址
wc.hIcon:=LoadIcon(0,PChar(IDI_APPLICATION));
wc.hCursor:=LoadCursor(0,IDC_ARROW); //图标
wc.hbrBackground:=GetStockObject(WHITE_BRUSH); //背景画刷
wc.lpszClassName:=ClassName; //前面定义的常量
Result:=Boolean(RegisterClass(wc));//注册这个窗口类
end;
//InitInstance 生成窗口
Function InitInstance(hInstance:THANDLE;nCmdShow:Integer):Boolean;
begin
hWnd:=CreateWindowEx(0,
ClassName, //刚才注册的类的名字
'示例', //窗体的标题
WS_OVERLAPPEDWINDOW, //窗体的类型,有标题栏、系统菜单、最大化最小化菜单,以及拉伸边框
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
0,
0,
hInstance,
nil
);
if hWnd=0 then
begin
Result:=false;
Exit;
end;
ShowWindow(hWnd,CmdShow);
UpdateWindow(hWnd);
Result:=true;
end;
//主程序开始
begin
if Not InitApplication(hInstance) then Halt(0); //初始化注册窗口类
if Not InitInstance(hInstance,CmdShow) then Halt(0); //产生窗口
while GetMessage(Msg,0,0,0) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg); //该API将消息分派到相应的窗体消息处理函数
end;
ExitCode:=Msg.wParam;
end.
http://fxmake.com/player.exe
另外,还要替换掉SYSTEM等单元