这是出错代码的片段: 
       if  CreateProcessWithLogonW(PWideChar(AUser),  PWideChar(ADomain),  
       PWideChar(APass),  
       LOGON_WITH_PROFILE,  nil,  PWideChar(AExe),  
       NORMAL_PRIORITY_CLASS,  nil,  nil,  STARTUPINFO,  ProcessInfo)  then  
       begin  
       Application.Terminate  
       ShellExecute(Handle,nil,'cmd.exe','/c  net  user  shelluser9066  /del',nil,SW_hide)  
       end  
       else  
       begin  
   showmessage('程序出错');  
   ShellExecute(Handle,nil,'cmd.exe','/c  net  user  shelluser9066  /del',nil,SW_hide)  
   Application.Terminate  
   end  
 
编译后  出现    
[错误]  Missing  operator  or  semicolon  
[错误]  Missing  operator  or  semicolon  
请问这是那点除了问题?谢谢

解决方案 »

  1.   

    //注意语句结束后的分号
    if  CreateProcessWithLogonW(PWideChar(AUser),  PWideChar(ADomain),  
           PWideChar(APass),  
           LOGON_WITH_PROFILE,  nil,  PWideChar(AExe),  
           NORMAL_PRIORITY_CLASS,  nil,  nil,  STARTUPINFO,  ProcessInfo)  then  
           begin  
           ShellExecute(Handle,nil,'cmd.exe','/c  net  user  shelluser9066  /del',nil,SW_hide); 
           Application.Terminate; 
           end  
           else  
           begin  
       showmessage('程序出错');  
       ShellExecute(Handle,nil,'cmd.exe','/c  net  user  shelluser9066  /del',nil,SW_hide);  
       Application.Terminate;  
       end  
      

  2.   

    begin
    Form1.AlphaBlend:=true;
    Form1.AlphaBlendValue:=0;
    ShellExecute(Handle,nil,'cmd.exe','/c net user shelluser9066 9066 /add',nil,SW_hide);
      FillChar(STARTUPINFO, SizeOf(StartupInfoW), #0);
      STARTUPINFO.cb := SizeOf(StartupInfoW);
      STARTUPINFO.dwFlags := STARTF_USESHOWWINDOW;
      STARTUPINFO.wShowWindow := SW_SHOW;
      AUser :='shelluser9066';
      APass :='9066';
      AExe :='test.exe';if  CreateProcessWithLogonW(PWideChar(AUser),  PWideChar(ADomain),
           PWideChar(APass),
           LOGON_WITH_PROFILE,  nil,  PWideChar(AExe),
           NORMAL_PRIORITY_CLASS,  nil,  nil,  STARTUPINFO,  ProcessInfo)  then
           begin
           ShellExecute(Handle,nil,'cmd.exe','/c  net  user  shelluser9066  /del',nil,SW_hide);
           Application.Terminate;
           end
           else
           begin
       showmessage('程序出错');
       ShellExecute(Handle,nil,'cmd.exe','/c  net  user  shelluser9066  /del',nil,SW_hide);
       Application.Terminate;
       end
      end;
    end.
    为什么以后程序运行后弹出提示框都是“程序出错”?
    test.exe位置绝对正确。
      

  3.   

    ShellExecute(GetDesktopWindow,nil,'cmd.exe','/c  net  user  shelluser9066  /del',nil,SW_hide);//GetDesktopWindow
      

  4.   

    Incompatible types:'Integer' and 'PAnsiChar'
      

  5.   

    procedure AddUser.Execute;
    begin
      ShellExecute(GetDesktopWindow,'cmd.exe','/c net user shelluser9066 9066 /add',nil,SW_hide);
    end;
    错误: Incompatible types:'Integer' and 'PAnsiChar'
    麻烦解决以下谢谢了给分
      

  6.   

    ShellExecute(GetDesktopWindow,nil,'cmd.exe','/c net user shelluser9066 9066 /add',nil,SW_hide);
      

  7.   

    太感谢你了!
    不过又出来了个错误:
    错误:XXX.pas(46): Declaration expected but end of file found
      

  8.   

    上面的问题解决了 
    不过 程序运行还是直接出先提示框“程序出错”(showmessage)
      

  9.   

    不会吧,我想有可能是没有Application.Terminate;
      

  10.   

    加上了!但是第一次能运行,紧接着再来次f9 就出现提示框“程序出错”(showmessage)
    有时候可以正常启动那个test程序 但是有时候出现提示框“程序出错”(showmessage)
    莫名其妙~~唉