program Note;uses Forms, Windows, SysUtils, main in 'main.pas' {NoteForm}, InputBox in 'InputBox.pas', about in 'about.pas' {Form2}, inforForm in 'inforForm.pas' {Form3};var RvHandle : hWnd; AHandle: Word; f: textfile; {$R *.res}
begin if GlobalFindAtom(PChar(Application.ExeName)) = 0 then begin Application.Initialize; Application.CreateForm(TNoteForm, NoteForm); Application.Run; end else begin RvHandle := FindWindow('TNoteForm', NIL); if RvHandle > 0 then begin if FileExists('NoteId.txt') then begin AssignFile(f, 'NoteId.txt'); reset(f); readln(f, AHandle); closeFile(f); if IsIconic(AHandle) then OPENICON(AHandle) else begin ShowWindow(RvHandle,SW_RESTORE); SetForegroundWindow(RvHandle); end; end; end; end;注:我这里是避免同一目录下的程序反复执行(允许不同目录下的相同程序运行),改一下就可以满足你的要求
Forms,
Windows,
SysUtils,
main in 'main.pas' {NoteForm},
InputBox in 'InputBox.pas',
about in 'about.pas' {Form2},
inforForm in 'inforForm.pas' {Form3};var
RvHandle : hWnd;
AHandle: Word;
f: textfile;
{$R *.res}
begin
if GlobalFindAtom(PChar(Application.ExeName)) = 0 then
begin
Application.Initialize;
Application.CreateForm(TNoteForm, NoteForm);
Application.Run;
end
else
begin
RvHandle := FindWindow('TNoteForm', NIL);
if RvHandle > 0 then
begin
if FileExists('NoteId.txt') then
begin
AssignFile(f, 'NoteId.txt');
reset(f);
readln(f, AHandle);
closeFile(f);
if IsIconic(AHandle) then OPENICON(AHandle)
else
begin
ShowWindow(RvHandle,SW_RESTORE);
SetForegroundWindow(RvHandle);
end;
end;
end;
end;注:我这里是避免同一目录下的程序反复执行(允许不同目录下的相同程序运行),改一下就可以满足你的要求
方法很多。
自己写也可以,使用原子即可