一段启动系统服务的…… 如果服务名中间有空格的是打死也启不了的。
'Alerter'是服务名 如果这个服务名中间带空格 就启不来了
你们千万别拦我网上能找源码的那段procedure tmainform.upserver;
var
Argv:PChar;
begin
schSCManager:=OpenSCManager(nil,nil,SC_MANAGER_ALL_ACCESS);
//server:=edit2.text ;
schService:=OpenService(schSCManager,'Alerter',SERVICE_ALL_ACCESS);
if StartService(schService,0,Argv) then
begin
Sleep(1000);
while (QueryServiceStatus(schService,ssStatus)) do
begin
Application.ProcessMessages;
if ssStatus.dwCurrentState=SERVICE_START_PENDING then
begin
MainForm.caption:=MainForm.caption+('.');
Sleep(1000);
end
else break;
end;
if ssStatus.dwCurrentState=SERVICE_RUNNING then
listbox1.items.add(DateTimeToStr(now())+'重新启用服务 Ok')
else listbox1.items.add(DateTimeToStr(now())+'服务正常');
end
else listbox1.items.add(DateTimeToStr(now())+'服务正常');
CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
end;
'Alerter'是服务名 如果这个服务名中间带空格 就启不来了
你们千万别拦我网上能找源码的那段procedure tmainform.upserver;
var
Argv:PChar;
begin
schSCManager:=OpenSCManager(nil,nil,SC_MANAGER_ALL_ACCESS);
//server:=edit2.text ;
schService:=OpenService(schSCManager,'Alerter',SERVICE_ALL_ACCESS);
if StartService(schService,0,Argv) then
begin
Sleep(1000);
while (QueryServiceStatus(schService,ssStatus)) do
begin
Application.ProcessMessages;
if ssStatus.dwCurrentState=SERVICE_START_PENDING then
begin
MainForm.caption:=MainForm.caption+('.');
Sleep(1000);
end
else break;
end;
if ssStatus.dwCurrentState=SERVICE_RUNNING then
listbox1.items.add(DateTimeToStr(now())+'重新启用服务 Ok')
else listbox1.items.add(DateTimeToStr(now())+'服务正常');
end
else listbox1.items.add(DateTimeToStr(now())+'服务正常');
CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
end;
解决方案 »
- 在wwDBGrid中显示的数据,选中部分数据做处理,怎么知道选中的笔数
- 请教XE上的FastReport怎么补齐空白行?
- 我想做一个adsl拨号程序。求教?(100)
- 能解决问题者有分: 如何解决给字段付值或将字段值导出的繁琐性!!!!!!!
- 关于TreeView
- F1book的中文问题?
- Ttable.edit后,Ttable.fieldbyname('字段名').asstring=值,出错
- *********简单问题 如何在程序里模拟实现ctrl+v************
- 如何取消数据登陆窗口直接进入程序?
- 怎样用delphi语句直接创建的sqlserver数据库,也就是说,用户不用直接操作sqlserver??
- 为什么用delphi7的TImage控件无法显示用photoshop转换来的.jpg文件呢?
- 要用到树视图,用什么控件好?for D7的。
LPCTSTR lpServiceName, // pointer to name of service to start
DWORD dwDesiredAccess // type of access to service
);
ParametershSCManagerIdentifies the service control manager (SCM) database. The OpenSCManager function returns this handle. lpServiceNamePoints to a null-terminated string that names the service to open. The maximum string length is 256 characters. The SCM database preserves the case of the characters, but service name comparisons are always case insensitive. A slash (/), backslash (\), comma, and space are invalid service name characters. 别自杀了,还是去补习英语吧
问题解决了 ysai所说的。。
不用自杀了。。
叫你们不要拦我的嘛~~真的是
谢谢 aloking(黑鲸) E文我更菜