我还用过ini呢,这就去查查怎么用吧!
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
var
Mutex: THandle;
{$R *.res}
begin
Mutex := CreateMutex(nil,True,'OneInstance');
if GetLastError<>ERROR_ALREADY_EXISTS then
begin
Application.Initialize;
Application.CreateForm(TfrmLogin, frmLogin);
Application.CreateForm(TfrmMain, frmMain);
Application.Run;
end else
begin
ShowMessage('程序已经运行!');
ReleaseMutex(Mutex);
end;
end.
谢谢楼上的了!
无奈,我还是看不懂呀!能不能再解释一哈!
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1}; file://这个语句什么意思呀?
var
Mutex: THandle;
{$R *.res}
begin
Mutex := CreateMutex(nil,True,'OneInstance');
if GetLastError<>ERROR_ALREADY_EXISTS then file://红色字迹部分是变量还是系统自 带的函数?
begin
Application.Initialize; file://application是对象吧?什么作用?
Application.CreateForm(TfrmLogin, frmLogin);//frmlogin、frmmain是需要提前
Application.CreateForm(TfrmMain, frmMain); // 创建的窗体吗?
Application.Run;
end else
begin
ShowMessage('程序已经运行!');
ReleaseMutex(Mutex);
虽然问题多了点,不过还是希望看得懂的网友别嫌麻烦,回复一下吧!
谢谢了!