Autor Beitrag
Grindfucker
Hält's aus hier
Beiträge: 5

WinXP

BeitragVerfasst: Mi 23.11.05 15:26 
Wie kann ich programme (zb. command.exe) öffnen lassen und automatisch etwas eintragen.

zb. (öffne)cmd, (schreibe)ping 127.0.0.1

mfg, Grind



edit: habe es mit SHELLEXECUTE probier aber das kennt er anscheinend nicht, habe auch in der Hilfe und mit dem Suchen button probiert. Ich weiß einfach nicht mehr weiter. Ich benutze Delphi 6.


Moderiert von user profile iconGausi: Topic aus Sonstiges verschoben am Mi 23.11.2005 um 15:38


Zuletzt bearbeitet von Grindfucker am Mi 23.11.05 15:39, insgesamt 1-mal bearbeitet
matze.de
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: Mi 23.11.05 15:38 
Guck dir mal die Befehle Suche in: Delphi-Forum SHELLEXECUTE (USES ShellAPI) und Suche in: Delphi-Forum SENDMESSAGE an.

mfg matze

_________________
si tacuisses, philosophus mansisses.
Grindfucker Threadstarter
Hält's aus hier
Beiträge: 5

WinXP

BeitragVerfasst: Mi 23.11.05 16:17 
Kannst du mir ein bespiel für SENDMESSAGE geben (vielleicht im Quelltext) wäre sehr nett.
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Mi 23.11.05 16:56 
user profile iconGrindfucker hat folgendes geschrieben:
habe es mit SHELLEXECUTE probier aber das kennt er anscheinend nicht

Einfach die Unit ShellAPI einbinden. ;-)

_________________
Ein Nutzer der Ecke ;-)
Pepe
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 107

Win 98, Win 2000 Prof., Win XP Prof.
Delphi 2005 Prof.
BeitragVerfasst: Mi 23.11.05 22:19 
WinExec('cmd /C ping 123.123.123.123', SW_SHOW);

sollte auch funktionieren...
Hux
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 171



BeitragVerfasst: So 27.11.05 16:16 
is vom Easy Helper:
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:
83:
84:
85:
function GetConsoleOutput(const Command: Stringvar Output, Errors: TStringList): Boolean;
var
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
  SecurityAttr: TSecurityAttributes;
  PipeOutputRead: THandle;
  PipeOutputWrite: THandle;
  PipeErrorsRead: THandle;
  PipeErrorsWrite: THandle;
  Succeed: Boolean;
  Buffer: array [0..255of Char;
  NumberOfBytesRead: DWORD;
  Stream: TMemoryStream;
begin
  //Initialisierung ProcessInfo
  FillChar(ProcessInfo, SizeOf(TProcessInformation), 0);

  //Initialisierung SecurityAttr
  FillChar(SecurityAttr, SizeOf(TSecurityAttributes), 0);
  SecurityAttr.nLength := SizeOf(SecurityAttr);
  SecurityAttr.bInheritHandle := true;
  SecurityAttr.lpSecurityDescriptor := nil;

  //Pipes erzeugen
  CreatePipe(PipeOutputRead, PipeOutputWrite, @SecurityAttr, 0);
  CreatePipe(PipeErrorsRead, PipeErrorsWrite, @SecurityAttr, 0);

  //Initialisierung StartupInfo
  FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
  StartupInfo.cb:=SizeOf(StartupInfo);
  StartupInfo.hStdInput := 0;
  StartupInfo.hStdOutput := PipeOutputWrite;
  StartupInfo.hStdError := PipeErrorsWrite;
  StartupInfo.wShowWindow := sw_Hide;
  StartupInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;

  if  CreateProcess(nil, PChar(command), nilnil, true,
  CREATE_DEFAULT_ERROR_MODE or CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nilnil,
  StartupInfo, ProcessInfo) then begin
    result:=true;
    //Write-Pipes schließen
    CloseHandle(PipeOutputWrite);
    CloseHandle(PipeErrorsWrite);

    //Ausgabe Read-Pipe auslesen
    Stream := TMemoryStream.Create;
    try
      while true do begin
        succeed := ReadFile(PipeOutputRead, Buffer, 255, NumberOfBytesRead, nil);
        if not succeed then break;
        Stream.Write(Buffer, NumberOfBytesRead);
      end;
      Stream.Position := 0;
      Output.LoadFromStream(Stream);
    finally
      Stream.Free;
    end;
    CloseHandle(PipeOutputRead);

    //Fehler Read-Pipe auslesen
    Stream := TMemoryStream.Create;
    try
      while true do begin
        succeed := ReadFile(PipeErrorsRead, Buffer, 255, NumberOfBytesRead, nil);
        if not succeed then break;
        Stream.Write(Buffer, NumberOfBytesRead);
      end;
      Stream.Position := 0;
      Errors.LoadFromStream(Stream);
    finally
      Stream.Free;
    end;
    CloseHandle(PipeErrorsRead);

    WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
    CloseHandle(ProcessInfo.hProcess);
  end
  else begin
    result:=false;
    CloseHandle(PipeOutputRead);
    CloseHandle(PipeOutputWrite);
    CloseHandle(PipeErrorsRead);
    CloseHandle(PipeErrorsWrite);
  end;
end;

So ruft man des danna uf:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.Button1Click(Sender: TObject);
var output, errors: TStringList;
begin
  output:=TStringList.Create;
  try
    errors:=TStringList.Create;
    if GetConsoleOutput('cmd /c dir c:\', output, errors) then
      Memo1.Lines.AddStrings(output);
  finally
    output.free;
    errors.free;
  end;
end;
Grindfucker Threadstarter
Hält's aus hier
Beiträge: 5

WinXP

BeitragVerfasst: Mi 30.11.05 09:56 
Vielen Dank, ich habe es geschafft

Mit WinExec('cmd /C ping 123.123.123.123', SW_SHOW); hat es geklappt
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 30.11.05 14:15 
user profile iconGrindfucker hat folgendes geschrieben:
Vielen Dank, ich habe es geschafft

Mit WinExec('cmd /C ping 123.123.123.123', SW_SHOW); hat es geklappt


WinExec ist von Microsoft als obsolt gekennzeichnet und nur noch aus kompatibilitäts Gründen vorhanden:
Zitat:

Note This function is provided only for compatibility with 16-bit Windows. Applications should use the CreateProcess function.

Benutz besser Shellexecute oder CreateProcess. Unter Windows Vista könnte sie schon nicht mehr vorhanden sein, da dort keine 16-Bit Programme mehr unterstützt werden.