3 Star 2 Fork 1

simpower91/simwebserver

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
simwebserver.dpr 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
simpower91 提交于 2018-02-02 13:54 +08:00 . 1
program simwebserver;
uses
//CheckMem,
SvcMgr,
Forms,
Windows,
SysUtils,
WinSvc,
SimNTService,
{SimSplash, }
fmmain in 'fmmain.pas' {frmmain},
fmVirtualPath in 'fmVirtualPath.pas' {frmVPath},
fmExtend in 'fmExtend.pas' {frmExtend},
fmDefaultFile in 'fmDefaultFile.pas' {frmDftFile};
{$R *.res}
function Installing: Boolean;
begin
Result := FindCmdLineSwitch('INSTALL',['-','\','/'], True) or
FindCmdLineSwitch('UNINSTALL',['-','\','/'], True);
end;
function StartService: 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(SServiceName), 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;
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;
begin
if not Installing then
begin
CreateMutex(nil, True, pchar(SimNTService.SServiceName));
if GetLastError = ERROR_ALREADY_EXISTS then
begin
MessageBox(0, PChar(SAlreadyRunning), PChar(SApplicationName), MB_ICONERROR);
Halt;
end;
end;
if Installing or StartService then
begin
SvcMgr.Application.Initialize;
SimService := TSimService.CreateNew(SvcMgr.Application, 0);
SvcMgr.Application.CreateForm(Tfrmmain, frmmain);
SvcMgr.Application.Run;
end else
begin
Application.Initialize;
//SimSplash.StartSplash;
Application.HelpFile := 'www.kapple.cn';
Application.Title := '٤web www.kapple.cn';
Application.CreateForm(Tfrmmain, frmmain);
//SimSplash.EndSplash;
Application.Run;
end;
end.
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Delphi
1
https://gitee.com/paud/simwebserver.git
[email protected]:paud/simwebserver.git
paud
simwebserver
simwebserver
master

搜索帮助