whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1548)

Database (90)
Files (137)
Forms (107)
Graphic (116)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Math (76)
Misc (127)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (243)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

16 Visitors Online


 
...run a process in the security context of another user?
Autor: Arndt Dienstbier
Homepage: http://www.ArViCor.DE
[ Print tip ]  

Tip Rating (8):  
     


uses
  
JwaWinBase; ( http://members.chello.nl/m.vanbrakel2/ )

//...

procedure TForm1.Button1Click(Sender: TObject);
var 
  
si: STARTUPINFOW; 
  pif: PROCESS_INFORMATION; 
  res: Bool;
  s: string;
begin
  
//erstmal die StartUpInfoW setzen
  //set StartUpInfoW first
  
si.cb := SizeOf(startupinfow);
  si.dwFlags  := STARTF_USESHOWWINDOW;
  si.wShowWindow := SW_SHOWDEFAULT;
  si.lpReserved := nil;
  si.lpDesktop := nil;
  si.lpTitle := 'Konsole';

  // dann CreateProcessWithLogonW ausführen...
  // run CreateProcessWithLogonW...
  
res := CreateProcessWithLogonW('Security', 'ArViCor', 'test', LOGON_WITH_PROFILE,
    'c:\win2kas\system32\regedt32.exe', nil
    
, CREATE_DEFAULT_ERROR_MODE, nilnil, si, pif);
  if booltostr(res) = '0' then 
  begin
    
//wenn ein Fehler auftritt, soll der Fehlercode ausgegeben werden
    //über 'net helpmsg ' in der Kommandoeingabeaufforderung
    //kann dieser entziffert werden

    //if an error occures, show the error-code
    //this code can be 'translated' with 'net helpmsg ' on command-prompt
    
str(GetLastError, s);
    ShowMessage('CreateProcessWithLogonResult: ' + booltostr(res) + #10 +
      'GetLastError: ' + s);
  end;
end;

// Verbesserungen gerne als Mail an mich!

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners