Autor Beitrag
Zeratul
Hält's aus hier
Beiträge: 1



BeitragVerfasst: Di 09.07.02 18:30 
HI ihr!

Ich hab da mal ne doofe Frage, obwohl vielleicht ist sie garnicht so doof:
Wie zum ***** bringe ich Delphi dazu eine bereits bestehende, mit dem Projekt in keinem Zusammenhang stehende .exe auszuführen? Ich hab' mir schon in der Hilfe die Finger wund gesucht. :(

Schon mal danke für alle Antworten!
Alfons-G
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 307

Win XP Prof, Linux, Win 7
D5 Prof, D7 Architect, D2005 Architect, D2007 Architect
BeitragVerfasst: Di 09.07.02 18:36 
Such' mal hier im Forum, bzw. in der mit Delphi gelieferten WinAPI-Hilfe nach ShellExecute, bzw. CreateProcess

:idea:

_________________
Alfons Grünewald
b.brecht
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: So 14.07.02 23:05 
also es gibt zwei wege:
1.
ausblenden Quelltext
1:
2:
uses ShellApi; 
ShellExecute(Handle, 'open', 'notepad.exe', '', nil, SW_SHOW);

2.
ausblenden Quelltext
1:
WinExec('C:\Windows\notepad.exe', SW_SHOW);					
b.brecht
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: So 14.07.02 23:06 
könnte Dir auch weiterhelfen:
ausblenden volle Höhe 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:
{1. With Winexec } 

procedure ExecuteShellCommand(cmdline: string; hidden: Boolean); 
const 
  flags: array [Boolean] of Integer = (SW_SHOWNORMAL, SW_HIDE); 
var 
  cmdbuffer: array [0..MAX_PATH] of Char; 
begin 
  GetEnvironmentVariable('COMSPEC', cmdBUffer, SizeOf(cmdBuffer)); 
  StrCat(cmdbuffer, ' /C '); 
  StrPCopy(StrEnd(cmdbuffer), cmdline); 
  WinExec(cmdbuffer, flags[hidden]); 
end; 


procedure TForm1.Button1Click(Sender: TObject); 
begin 
  ExecuteShellCommand('dir C:\ > c:\temp\dirlist.txt', True); 
end; 


{2. With Shellexecute } 

procedure ExecuteShellCommand(cmdline: string; hidden: Boolean); 
const 
  flags: array[Boolean] of Integer = (SW_SHOWNORMAL, SW_HIDE); 
var 
  cmdbuffer: array[0..MAX_PATH] of Char; 
begin 
  GetEnvironmentVariable('COMSPEC', cmdBUffer, SizeOf(cmdBuffer)); 
  ShellExecute(0,'open',cmdbuffer, PChar('/c' + cmdline), nil, flags[hidden]); 
end; 

procedure TForm1.Button1Click(Sender: TObject); 
begin 
  ExecuteShellCommand('copy file1.txt file2.txt', True); 
end;