unit Define; interface uses Tocsg.Param, Winapi.Windows, System.SysUtils; const APP_NAME = 'bs1rcd'; DAT_PARAM = '#prcd.dat'; MUTEX_NAME = 'Global\251120bs1rcd'; {$IFDEF WIN64} DIR_AVLIB = 'avlib64\'; {$ELSE} DIR_AVLIB = 'avlib\'; {$ENDIF} type TTaskInfo = record hRcvWnd: HWND; llTasker: LONGLONG; sApps, sTaskDir: String; nMaxMain: Integer; end; TExeType = (etNone, etTest, etRecordWait, etRecordConn); TProcessParam = class(TTgParam) private ExeType_: TExeType; TaskInfo_: TTaskInfo; sOwMtxName_: String; public Constructor Create; Destructor Destroy; override; function ProcessParam: Boolean; property ExeType: TExeType read ExeType_; property TaskInfo: TTaskInfo read TaskInfo_; property OwMtxName: String read sOwMtxName_; end; var gParam: TProcessParam = nil; implementation uses Tocsg.Path, superobject; { TProcessParam } Constructor TProcessParam.Create; begin Inherited Create; ASSERT(gParam = nil); gParam := Self; ExeType_ := etNone; ZeroMemory(@TaskInfo_, SizeOf(TaskInfo_)); end; Destructor TProcessParam.Destroy; begin gParam := nil; Inherited; end; function TProcessParam.ProcessParam: Boolean; var sPath: String; O: ISuperObject; begin Result := false; if ExistsParam('-test_rcd') then begin Result := true; ExeType_ := etTest; exit; end; sPath := GetParamValue('-p'); if sPath = '' then sPath := GetRunExePathDir + DAT_PARAM; if FileExists(sPath) then begin try if not LoadJsonObjFromFile(O, sPath) then exit; case O.I['Cmd'] of 1 : begin ExeType_ := etRecordWait; TaskInfo_.hRcvWnd := O.I['RcvWnd']; TaskInfo_.llTasker := O.I['Tasker']; TaskInfo_.sApps := O.S['Apps']; TaskInfo_.sTaskDir := O.S['TaskDir']; TaskInfo_.nMaxMain := O.I['MaxMin']; sOwMtxName_ := O.S['OwMtx']; end; else exit; end; Result := true; finally {$IFNDEF DEBUG} DeleteFile(sPath); {$ENDIF} end; end; end; end.