if Findwindow(NULL,"程序标题") then
begin
{已经有程序运行所做处理。}
end
else
begin
{程序还没运行所做处理。}
end;
大概就是这样,抱歉有些日子没用DELPHI了。语法可能不是很准确。
begin
{已经有程序运行所做处理。}
end
else
begin
{程序还没运行所做处理。}
end;
大概就是这样,抱歉有些日子没用DELPHI了。语法可能不是很准确。
解决方案 »
- 伤心程序员
- 问个简单问题--封装窗体
- 拜托,哪位高手指点一下
- 求教酒店仓库管理系统需要的一些模块及大概说明
- const char a='1';编译后出错,内容如下:
- 问一个很菜的IDE问题(vcl组件栏上的show hints)
- ##### 关于DataModule的使用方法 #####大侠帮忙啊
- 更新delphi可执行文件后运行提示:"参数不正确"
- 对showmessage或MessageBox中的信息如何换行?
- sql中的查询搜索
- 在Delphi中怎样使用GetWindowDirectory函数?
- 日期如何通过ansi方式比较,在commandtext中(WHERE dm>='2001.12.25')
Forms, Windows, Messages,
Unit1 in 'Unit1.pas' {Form1};const
CM_RESTORE = WM_USER + $1000;var
RvHandle : hWnd;{$R *.RES}begin
{If there's another instance already running, activate that one}
RvHandle := FindWindow('My Delphi program!', NIL);
if RvHandle > 0 then
begin
PostMessage(RvHandle, CM_RESTORE, 0, 0);
Exit;
end; {Else, do the normal stuff}
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;end.
Prev:Variant;
begin
Application.Initialize;
Prev:=findwindow('主窗体名称','主窗休标题');
if prev<>0 then
begin
showmessage('该程序已经在运行!');
setforeGroundWindow(Prev);
Application.Terminate ;
end
else
begin
Application.CreateForm(TmF_Main, mF_Main);
Application.Run;
end;
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
);
hPrevInstance可以判断