Autor Beitrag
ebs
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 213

Suse Linux 9.2, Win 98, Win NT, Win XP, Win for Workgroups, Win XP SP2, Dos 6.1
D3 Prof, D2005 PE, Delphi 2006 Prof.
BeitragVerfasst: So 10.04.05 12:43 
Hallo!
Ich habe ein Problem mit shellexecute. Ich habe hier eine neuere Version davon(Um zu warten):
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:
function ShellExecuteAndWaitW(hWnd: HWND; Operation, FileName, Parameters, Directory: PWideChar; ShowCmd: Integer; bWait: BOOL): HINST; stdcall;
var
  sei: TShellExecuteInfoW;
begin
// Delete any contents of this variable (undetermined for complex types)
  ZeroMemory(@sei, sizeof(sei));
// Fill the information structure with all ShellExecute standard parameters
  with sei do
  begin
    cbSize := sizeof(sei);
    fMask := SEE_MASK_NOCLOSEPROCESS; // we want a process handle returned!
    Wnd := hWnd;
    lpVerb := Operation; // Pre-defined: edit, explore, find, open, print, nil
    lpFile := FileName;
    lpParameters := Parameters;
    lpDirectory := Directory;
    nShow := ShowCmd;
  end;
// Call ShellExecuteEx()
  if ShellExecuteExW(@sei) then
  try
    if bWait then
      WaitForSingleObject(sei.hProcess, INFINITE);
  finally
// Close references to new process! THIS ALSO NEEDS TO BE DONE IF THE PROCESS
// IS ALREADY FINISHED WITH EXECUTION!!!
    CloseHandle(sei.hProcess);
  end;
// Return a value (not actually HINST, as with ShellExecute! ... see Platform SDK)
  result := sei.hInstApp;
end;

So wollte ich eigentlich das Programm starten:
ausblenden Delphi-Quelltext
1:
ShellExecuteAndWaitW(Application.Handle, nil, 'command', '/c d1.exe 0<datfile 1>datfile.bho' ,{Problemstelle-->}PWidechar(extractfilepath(Application.ExeName)), SW_Show, true);					

Klappt nur nicht, sondern das Programm bleibt hängen. Nur wenn ich das Verzeichniss direkt angebe klappst.
Hat einer ne Idee wie ich das Programm so starten kann, wie oben angegeben?
Danke!
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 12.04.05 10:30 
1. würde ich Suche in: Delphi-Forum, Delphi-Library CREATEPROCESS empfehlen
und
2. kannst du ja versuchen, mit ChangeCurrentDirectory (hoffe so war der Befehl) das aktuelle Verzeichnis vorher auf das Zielverzeichnis zu setzen...
ebs Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 213

Suse Linux 9.2, Win 98, Win NT, Win XP, Win for Workgroups, Win XP SP2, Dos 6.1
D3 Prof, D2005 PE, Delphi 2006 Prof.
BeitragVerfasst: Di 12.04.05 13:48 
(1) Ich kann mit diesem Shellexecute deutlich besser arbeiten, und es läuft nach meinen Erfahrungen deutlich besser als CreateProcess.
(2)Mein Delphi kennt diesen Befehl nicht!