ipserver.dpr

来自「群星医药系统源码」· DPR 代码 · 共 37 行

DPR
37
字号
program IPServer;

uses
  Windows,
  Forms,
  GlobalUnit in 'GlobalUnit.pas',
  IPServer_TLB in 'IPServer_TLB.pas',
  TcpCom in 'TcpCom.pas' {TcpServer: TRemoteDataModule} {TcpServer: CoClass},
  IpProcess in 'IpProcess.pas' {FmMsgServer},
  SettingFM in 'SettingFM.pas' {FmSetting};

{$R *.TLB}

{$R *.res}

var
  hMutex : THandle;
  WaitResult : word;
  BroadcastList : DWORD;
begin
  MessageID := RegisterWindowMessage('ChainEnt MsgServer');
  hMutex := createMutex(nil,false,pchar('App_ChainEnt.MsgServer')); // grab a mutex handle
  WaitResult := WaitForSingleObject(hMutex,10); // wait to see if we can have exclusive use of the mutex
  if ( waitResult = WAIT_TIMEOUT ) then // if we can't then broadcast the message to make the owner of the mutex respond
  begin { request that the running application takes focus }
    BroadcastList := BSM_APPLICATIONS;
    BroadcastSystemMessage(BSF_POSTMESSAGE,@BroadcastList,MessageID,0,0);
    //32 bit - broadcast the message to all apps - only a prev inst will hear it.
  end else begin  { do the normal stuff}
    Application.Initialize;
    Application.CreateForm(TFmMsgServer, FmMsgServer);
    Application.Run;
    ReleaseMutex(hMutex); // release the mutex as a politeness
  end;
  CloseHandle(hMutex); // close the mutex handle
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?