看如下代码 对你有所帮助
program HttpRecSend;
uses
windows,
Forms,
RecSendU in 'RecSendU.pas' {HttpRecSendF},
ThrdU in 'ThrdU.pas';
{$R *.res}
begin
Application.Initialize;
MessageID := RegisterWindowMessage('HttpRecSendMessage');
MutexRun := OpenMutex(MUTEX_ALL_ACCESS, false, Pchar('RunHttpRecSnd'));
if MutexRun = 0 then
begin
CreateMutex(nil, false, Pchar('RunHttpRecSnd'));
Application.CreateForm(THttpRecSendF, HttpRecSendF);
Application.Run;
end
else
begin
CloseHandle(MutexRun);
PostMessage(HWND_BROADCAST, MessageID, 0, 0);
end;
end.
unit RecSendU;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
THttpRecSendF = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
HttpRecSendF: THttpRecSendF;
MutexRun: THandle = 0; //同时只允许运行一个实例;
implementation
{$R *.dfm}
end.