Autor Beitrag
Webo
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 577
Erhaltene Danke: 14

Win 7, Debian
C# (Visual Studio 2013), PHP, C, C++ (Eclipse, KDevelop)
BeitragVerfasst: Di 15.02.11 11:54 
Moin, moin ...

Ich experimentiere grade mit diesem Code herum. Allerdings funktioniert es bei mir schon so nicht, wie er da steht. Ich weiß, dass ich damit früher schonmal rumgespielt habe und da hat es funktioniert.
So, zum Fehler: Ich habe zuerst einfach das Beispiel von dort genommen. Es kommt aber eine Zugriffsverletzung, siehe Anhang. Das passiert unter Windows 7, als auch in einer XP-VM. Ich bin das mal durchgegangen und der Fehler tritt in der Zeile
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
 if CreateProcess(nil,
                   PChar(Command),
                   nil,
                   nil,
                   True,
                   CreationFlags,
                   nil,
                   nil,
                   StartupInfo,
                   ProcessInfo) then
  begin

auf.
Jetzt bin ich irgendwie ratlos, wie ich den Fehler beheben könnte. Vielleicht weiß von Euch jmd Rat ?

MfG

Webo


PS: Ausführen als Administrator brachte auch keinen Erfolg.
Einloggen, um Attachments anzusehen!
_________________
Man kann nur das aus dem Ärmel schütteln, was man auch vorher reingesteckt hat.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19315
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 15.02.11 12:39 
Das ist bestimmt ein Unicodeproblem, wenn du D2010 grad nutzt. Ich kanns grad nicht testen, versuchs erst einmal mit Ansistrings, ich schaue es mir zu Hause einmal an:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
function GetConsoleOutput(const Command : AnsiString;
                          Output, Errors : TStringList) : Boolean;
var
  Buffer            : array[0..255of AnsiChar;
  StartupInfo       : TStartupInfoA;

...


  if CreateProcessA(nil,
                   PAnsiChar(Command),
...
// EDIT:
Die Deklaration in Delphi ist falsch bzgl. Unicode, siehe MSDN Doku, mehr heute Abend...
// EDIT2:
www.delphifeeds.com/go/s/62569
Webo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 577
Erhaltene Danke: 14

Win 7, Debian
C# (Visual Studio 2013), PHP, C, C++ (Eclipse, KDevelop)
BeitragVerfasst: Mi 16.02.11 12:46 
Danke für die Antwort. Warum es nicht funktioniert habe ich jetzt verstanden, aber wie genau ändert man das ? Auf der verlinkten Seite steht ja, dass man sich zwei neue, überladene Funktionen nutzen muss. Nur wie ? :D

_________________
Man kann nur das aus dem Ärmel schütteln, was man auch vorher reingesteckt hat.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19315
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 18.02.11 12:17 
Einfachster Fix:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
  if CreateProcess(nil,
                   PChar(Command + ''),
                   nil,
                   nil,
                   True,
                   CreationFlags,
                   nil,
                   nil,
                   StartupInfo,
                   ProcessInfo) then
  begin
Webo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 577
Erhaltene Danke: 14

Win 7, Debian
C# (Visual Studio 2013), PHP, C, C++ (Eclipse, KDevelop)
BeitragVerfasst: Fr 18.02.11 19:30 
Funktioniert. Dankeschön! 8)

_________________
Man kann nur das aus dem Ärmel schütteln, was man auch vorher reingesteckt hat.