Autor Beitrag
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 23.10.05 20:45 
user profile iconKoller hat folgendes geschrieben:
:shocked: DU hast ja keine Formulare. Das musst du mir genauer erklären!!!!

Ohne VCL eben.

Zitat:

Deshalb weiß ich auch nichts mit dem Code anzufangen, weil ich nicht weiß, welche Funktion was macht. Allein am Funktionsnamen erkenn ich auch nich alles. KAnnste den betreffenden Codeauszug mal bitte posten?????

:autsch:
Nur mal bitte für 5 Sekunden nachdenken. Da dürfte einem die Unit RunDlg.pas auffallen. man könnte sie ja mal auf gut Glück öffnen. Dann sieht man, dass sie genau drei Funktionen beinhaltet:
ausblenden Delphi-Quelltext
1:
2:
function CreateProcessAsLogon(const User, PW, Application, CmdLine:
  WideString): LongWord;

ausblenden Delphi-Quelltext
1:
function GetCompName: string;					

und
ausblenden Delphi-Quelltext
1:
2:
function RunDlgFunc(hDlg: hWnd; uMsg: DWORD; wParam: wParam; lParam: lParam):
  bool; stdcall;

Und jetzt die absolut schwere Frage: Welche Funktion dürfte wohl dafür verantwortlich sein, einen Prozess unter einem anderen Benutzeraccount zu starten?

Und du willst mir jetzt erzählen, du hättest mal in den Quellcode reingeguckt? Sorry, das nehme ich dir nicht ab.

Wegen deiner E-Mail:
Was das const in der Parameterdeklaration zu suchen hat, guckst du in der Delphi Hilfe nach.
Ich hätte natürlich auch true oder false zurückgeben können, aber wenn ich dann wissen will, warum es nicht funktioniert hat muss ich ja trotzdem noch mal GetLastError aufrufen und so gebe ich ihn eben gleich zurück und kann ihn auswerten. Wenn er null ist, ist alles in Ordnung, ist er ungleich null kann ich mit SysErrorMessage gleich eine aussagekräftige Fehlermeldung ausgeben.
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 26.10.05 19:13 
@ Luckie:

Also

ausblenden Delphi-Quelltext
1:
2:
function CreateProcessAsLogon(const User, PW, Application, CmdLine:
  WideString): LongWord;


Als ich ausprobiert habe, da startete kein Programm. Was muss ich denn schreiben um die kommandozeile als 'Administrator' mit dem PAsswort 'admin' zu öffnen?

MFG KOLLER

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 26.10.05 21:28 
Und was gibt GetLastError für einen Fehlercode zurück? Wie ich dir oben erklärt habe, hab eich das ganze doch schon so implementiert, dass man sieht, was nicht geklappt hat, wenn es nicht geht. Aber wen man das nicht nutzt, dann kann ich auch nicht helfen.
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 28.10.05 21:26 
@ Luckie:

Jetzt check ich was du meinst :autsch: :autsch: :autsch: :autsch: :autsch:

Also nummer 1326: ANmeldung fehlgeschlagen, unbekannter benutzername oder falsches Kennwort. Also dass kann nicht sein, ich werd ja wohl noch mein Kennwort wissen :wink:

:gruebel: Also ich hab mal nen neues konto erstellt und als ich das genommen habe hat es funktioniert :nixweiss:

Das ist sehr komisch

also hier der code

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
var
  Form1: TForm1;  l:longword;

implementation

{$R *.dfm}

function CreateProcessAsLogon( User, PW, Application, CmdLine: WideString):
  LongWord;
var
  si           : TStartupInfoW;
  pif          : TProcessInformation;
  s: WideString;
begin
  ZeroMemory(@si, sizeof(si));
  si.cb := sizeof(si);
  si.dwFlags := STARTF_USESHOWWINDOW;
  si.wShowWindow := 1;

  SetLastError(0);

  if CmdLine = '' then
    s := Application
  else
    s := Application+' "'+CmdLine+'"';

  CreateProcessWithLogonW(PWideChar(User), nil, PWideChar(PW),
    LOGON_WITH_PROFILE, nil, PWideChar(s),
    CREATE_DEFAULT_ERROR_MODE, nilnil, @si, @pif);
  Result := GetLastError; 
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
l:=createprocessaslogon('Screenex','nept','C:/WINDOWS/system32/cmd.exe','net send PC104 uschi');
showmessage(inttostr(l));
showmessage(syserrormessage(l));
end;

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 28.10.05 22:44 
ALso jetzt funktioniert alles :D

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 29.10.05 20:02 
Also dat geht jetzt irgendwie nicht mehr :bawling:

Ich weiß wie gesagt nicht, was man in die Klammern schreiben soll hier der code:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
unit main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, jpeg, StdCtrls, mpuwinnt;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Image2: TImage;
    Image3: TImage;
    Timer1: TTimer;
    Timer2: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
   
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1; l1,l2:longword;

implementation

{$R *.dfm}

function CreateProcessAsLogon( User, PW, Application, CmdLine: WideString):
  LongWord;
var
  si           : TStartupInfoW;
  pif          : TProcessInformation;
  s: WideString;
begin
  ZeroMemory(@si, sizeof(si));
  si.cb := sizeof(si);
  si.dwFlags := STARTF_USESHOWWINDOW;
  si.wShowWindow := 1;

  SetLastError(0);

  if CmdLine = '' then
    s := Application
  else
    s := Application+' "'+CmdLine+'"';

  CreateProcessWithLogonW(PWideChar(User), nil, PWideChar(PW),
    LOGON_WITH_PROFILE, nil, PWideChar(s),
    CREATE_DEFAULT_ERROR_MODE, nilnil, @si, @pif);
  Result := GetLastError; 
end;



procedure TForm1.Timer1Timer(Sender: TObject);
begin
timer1.enabled:=false;
l1:=createprocessaslogon('Admin','admin','sc config messenger start= demand','sc config messenger start= demand');
l2:=createprocessaslogon('Admin','admin','net start messenger','net start messenger');
if (l1<>0or (l2<>0then
begin
messagedlg('ERROR: CODE1 '+inttostr(l1),mterror,[mbok],0);
messagedlg('ERROR: CODE2 '+inttostr(l2),mterror,[mbok],0);
close;
end
else begin
messagedlg('Windows Messenger Service started succesfully.',mtinformation,[mbok],0);
close;
end;

end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
application.BringToFront;
end;

end.


Könnt ihr das mal bitte berichtigen??? :flehan:

KOLLER

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 31.10.05 00:58 
In was denn für Klammern um Gottes Willen? Der Funktion CreateProcessAsLogon übergibst du den Bneutzernamen, dessen Passowrt, das zu startende Programm und wenn nötig noch Paramter für das Programm. Ist das denn so schwer an Hand der Parameter: User, PW, Application, CmdLine zu erschließen? :roll:
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mo 31.10.05 12:03 
@ Luckie:

Ich dachte immer 'cmdLine' hat was mit cmd zu tun, also mit der kommandozeile. Mensch, mehr wollt ich doch gar nicht wissen :P :wink: :P :wink: :P :roll: :twisted: :wink: :twisted: :wink:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot