Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 03.05.10 07:22 
Hi, Delpher,
ich habe jetzt von XP auf Win7 gewechselt. Natürlich klappt dann der folgende Aufruf
nicht mehr:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TBuchMain.to_do(Sender: TObject);
begin
  ShellExecute(Handle, nil, PChar('C:\WINXP\notepad.exe'),
    PChar(label30.caption+ 'to_do.txt'), nil, SW_Show);
end;


Gibt es eine Möglichkeit, den Ort, wo das Programm jetzt liegt, per Code herauszufinden,
und dann mit shellexecute darauf zuzugreifen?

Danke, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
zuma
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 660
Erhaltene Danke: 21

Win XP, Win7, Win 8
D7 Enterprise, Delphi XE, Interbase (5 - XE)
BeitragVerfasst: Mo 03.05.10 07:36 
versuchs mal so
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TBuchMain.to_do(Sender: TObject);
begin
  ShellExecute(Handle, nil, PChar('notepad.exe'),
    PChar(label30.caption+ 'to_do.txt'), nil, SW_Show);
end;

_________________
Ich habe nichts gegen Fremde. Aber diese Fremden sind nicht von hier! (Methusalix)
Warum sich Sorgen ums Leben machen? Keiner überlebts!
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 03.05.10 08:16 
Klappt leider nicht!
Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Mo 03.05.10 08:23 
Vielleicht sollte man auch eine Operation wie PChar('open') verwenden, damit Windows auch weiß was es tun soll. ;) In diesem Fall hätte dir MSDN oder Google oder die Forensuche sicher weitergeholfen!!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TBuchMain.to_do(Sender: TObject);
begin
  ShellExecute(Handle, PChar('open'), PChar('notepad.exe'),
    PChar(label30.caption+ 'to_do.txt'), nil, SW_Show);
end;


lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 03.05.10 08:43 
Das klappt leider immer noch nicht!

_________________
ut vires desint, tamen est laudanda voluntas
thepaine91
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 763
Erhaltene Danke: 27

Win XP, Windows 7, (Linux)
D6, D2010, C#, PHP, Java(Android), HTML/Js
BeitragVerfasst: Mo 03.05.10 09:08 
Suche im MSDN GETSYSTEMDIRECTORY so kannst du zuverlässig den Pfad in dem Notepad liegt ansteuern.
Dann sollte es theoretisch funktionieren wenn nicht kannst du ja mal ShellexecuteEX probieren.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Mo 03.05.10 09:35 
Was ist die Fehlermeldung? Mach mal:
ausblenden Delphi-Quelltext
1:
2:
  if ShellExecute(...) <= 32 then
    RaiseLastOSError;
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 03.05.10 10:07 
Ich taste mich da jetzt ran, aber es geht noch nicht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
function SystemDir: string;
var dir: array [0..MAX_PATH] of Char;
begin
  GetSystemDirectory(dir, MAX_PATH);
  Result := StrPas(dir);
end;

procedure TBuchMain.to_do(Sender: TObject);
begin
  showmessage(systemdir);
  ShellExecute(Handle, PChar('open'), PChar('notepad.exe'),
    PChar(label30.caption+ 'to_do.txt'), nil, SW_Show);
end;


Keine Fehlermeldung, aber es tut sich auch nichts. Wie ist es richtig?
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 03.05.10 10:47 
elundril, du hattest recht.
Bei mir war allerdings noch etwas anderes verstellt durch den
Systemwechsel - jetzt klappt es bestens, auch ohne GetSystemDir oder so.
Danke, Detlef

_________________
ut vires desint, tamen est laudanda voluntas