一段启动系统服务的…… 如果服务名中间有空格的是打死也启不了的。
'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;

解决方案 »

  1.   

    SC_HANDLE OpenService(    SC_HANDLE hSCManager, // handle to service control manager database  
        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. 别自杀了,还是去补习英语吧
      

  2.   

    55555555
    问题解决了  ysai所说的。。
    不用自杀了。。
    叫你们不要拦我的嘛~~真的是
    谢谢 aloking(黑鲸) E文我更菜