Autor Beitrag
foxy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 814

Ubuntu, Gentoo
C++, PHP, Java, Ruby, Perl (Eclipse)
BeitragVerfasst: Di 21.01.03 11:25 
Guden all ma ne Frage
Also der Befehl für ShellExecute iss ja so
ausblenden Quelltext
1:
ShellExecute(Application.Handle, 'open' ,PChar('xy.exe'), nil, PChar('c:\test'), sw_ShowNormal);					

ich will zu bestimmten Datein, wie .pdf ;.doc etc. die bestimmten Programme öffnen dazu extrhiere ich die endung der Datein und suche in der registry nach den dazugehörigen programmen und zwar so
GetExe(ExtractFileExt(pfad));
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:
function GetExe(Ext:string):string;
var reg    : TRegistry;
    s      : String;
Begin
  s:='';
  reg:=TRegistry.Create;
  reg.RootKey:=HKEY_CLASSES_ROOT;
  if reg.OpenKey('.'+ext+'\shell\open\command', false) then
   begin
    s:=reg.ReadString('');
    reg.CloseKey;
  end
  else begin
    if reg.OpenKey('.'+ext, false) then begin
      s:=reg.ReadString('');
      reg.CloseKey;
      if s<>'' then begin
        if reg.OpenKey(s+'\shell\open\command', false) then
          s:=reg.ReadString('');
          reg.CloseKey;
      end;
    end;
  end;
  if Pos('%', s)>0 then
    Delete(s, Pos('%', s), length(s));
  if ((length(s)>0) and (s[1]='"')) then
    Delete(s, 1, 1);
  if ((length(s)>0) and (s[length(s)]='"')) then
    Delete(s, Length(s), 1);
  while ((length(s)>0) and
   ((s[length(s)]=#32) or (s[length(s)] = '"'))) do
    Delete(s, Length(s), 1);
  result := s;
end;

aber jetzt habe ich das problem wie ich das in shellexecute einbaue, da ich ja variablen pfad habe und variable namen der .exe dateien....

_________________
"Only wimps use tape backup: real men just upload their important stuff on ftp, and let the rest of the world mirror it." (Linus Torvalds)
OperatingSystem Laptop (Ubuntu Hardy)
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Di 21.01.03 11:32 
Hallo,

den Aufwand, den Du mit der Registry betreibst, ist in Deinem Fall nicht notwendig. Wenn z.B. der Acrobat Reader installiert ist, den ist der Dateityp pdf bereits registriert. Dadurch genügt es, Shellexecute mit dem Namen der Datei aufzurufen (ähnlich wie ein Doppelklick im Explorer).

ausblenden Quelltext
1:
ShellExecute(Application.Handle, 'open' ,PChar('Tutorial.pdf'), nil, nil, sw_ShowNormal);					

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
foxy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 814

Ubuntu, Gentoo
C++, PHP, Java, Ruby, Perl (Eclipse)
BeitragVerfasst: Di 21.01.03 11:33 
ja?? hmmm dann hat mir einer quatsch erzählt :lol: dann versuch ich das ma so vielen dank für die hilfe

_________________
"Only wimps use tape backup: real men just upload their important stuff on ftp, and let the rest of the world mirror it." (Linus Torvalds)
OperatingSystem Laptop (Ubuntu Hardy)
foxy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 814

Ubuntu, Gentoo
C++, PHP, Java, Ruby, Perl (Eclipse)
BeitragVerfasst: Di 21.01.03 11:55 
hmm also ich habe das nu so gemacht
ausblenden Quelltext
1:
2:
name := ExtractFileName(Table1.FieldByName('File').AsString);
ShellExecute(Application.Handle, 'open' ,PChar(name), nil, nil, sw_ShowNormal);

aber dann kommt da

Diagramm1.bmp ist kein gültiger komponentenname
in der zeile wo execute steht??? mach ich was falsch??

_________________
"Only wimps use tape backup: real men just upload their important stuff on ftp, and let the rest of the world mirror it." (Linus Torvalds)
OperatingSystem Laptop (Ubuntu Hardy)
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Di 21.01.03 12:04 
Hallo,

Du musst schon den Pfad zu dem Dokument mit angeben. Woher soll sonst Shellexecute wissen, wo sich die Datei genau befindet.

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
foxy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 814

Ubuntu, Gentoo
C++, PHP, Java, Ruby, Perl (Eclipse)
BeitragVerfasst: Di 21.01.03 13:04 
hmm geht imma noch nich ... :(
so sieht mein code aus
ausblenden Quelltext
1:
2:
3:
4:
name := ExtractFileName(Table1.FieldByName('File').AsString);
    path:=ExtractFilePath(Table1.FieldByName('File').AsString);

    ShellExecute(Application.Handle, 'open' ,PChar(name), nil, PChar(Path), sw_ShowNormal);

kommt der selbe fehler !! ka was das iss .... das mit dem komponentenNamen

_________________
"Only wimps use tape backup: real men just upload their important stuff on ftp, and let the rest of the world mirror it." (Linus Torvalds)
OperatingSystem Laptop (Ubuntu Hardy)
foxy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 814

Ubuntu, Gentoo
C++, PHP, Java, Ruby, Perl (Eclipse)
BeitragVerfasst: Di 21.01.03 13:41 
iss ok hab den fehler gefunden,
name die variable habe ich nich definiert und die wird standartmässig definiert über die Uses ShellAPI dabei iss name eine komponente wenn man nun name deklariert als String dann gehts thx an alle

_________________
"Only wimps use tape backup: real men just upload their important stuff on ftp, and let the rest of the world mirror it." (Linus Torvalds)
OperatingSystem Laptop (Ubuntu Hardy)
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Di 21.01.03 16:16 
Hallo,

es geht noch kürzer:
Du musst Deinen Dateinamen nicht zerlegen. Wundert mich, dass das so geht.

ausblenden Quelltext
1:
ShellExecute(Application.Handle, 'open' ,PChar(Table1.FieldByName('File').AsString), nil, nil, sw_ShowNormal);					

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)