Autor Beitrag
shana-chan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Fr 25.11.11 12:48 
Hallo,

Ich habe ein Projekt mit einem TWebbrowser in dem ich eine Webseite aus eine Resource lade.

Wenn in dieser Webseite einen Link zu einer Datei hab, die ebenfalls als Resource vorhanden ist, sieht das z.B. so aus:
<a href="../JPEG/bild">

Aber wie kann ich auf eine Datei zugreifen, die sich im gleichem Verzeichnis wie das Projekt befindet?
(G:/Projekt/SD-Karte/_Sandbox/Projekt1.exe)

Dass funktioniert:
<a href="G:/Projekt/SD-Karte/_Sandbox/Software/Editor1.exe">
Aber da ich nicht weis, wo sich Das projekt nachher befindet, kann ich kein absolutes Verzeichnis angeben.


Konnte leider nichts finden, weis aber auch nicht wonach ich suchen soll.

Hoffe man kann mir hier helfen.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 25.11.11 13:55 
ExtractFileDir(ParamStr(0)); liefert das Verzeichnis, in dem sich die Exe befindet. Alternativ ExtractFileDir - das eine ist mit dem abschließenden \, das andere ohne.

_________________
We are, we were and will not be.
shana-chan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Mo 28.11.11 13:59 
Hatte eigentlich gehofft, dass man in der HTML irgendwas angeben kann, dass er aus dem Resource Bereich raus geht.

Hab es jetzt so gelöst:

HTML:
<a href="http://!/Software/Editor1.exe">Editor starten</a>

Delphi:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
  const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
  Headers: OleVariant; var Cancel: WordBool);
  var newURL: String;
begin
  newURL:=StringReplace(URL,'http://!',ExtractFileDir(ParamStr(0)),[rfReplaceAll,rfIgnoreCase]);
  if not(URL=newURL)
    then
      begin
        Cancel:=True;
        webbrowser1.Navigate(newURL);
      end;
end;
baka0815
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 489
Erhaltene Danke: 14

Win 10, Win 8, Debian GNU/Linux
Delphi 10.1 Berlin, Java, C#
BeitragVerfasst: Mo 28.11.11 15:01 
user profile iconGausi hat folgendes geschrieben Zum zitierten Posting springen:
ExtractFileDir(ParamStr(0)); liefert das Verzeichnis, in dem sich die Exe befindet. Alternativ ExtractFileDir - das eine ist mit dem abschließenden \, das andere ohne.

Du meinst einmal ExtractFilePath. ;-)
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 28.11.11 15:05 
user profile iconbaka0815 hat folgendes geschrieben Zum zitierten Posting springen:
Du meinst einmal ExtractFilePath. ;-)

Da kannst du mal sehen, wie sehr ich die beiden ständig verwechlse. :lol:

_________________
We are, we were and will not be.
JungerIslaender
ontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 427
Erhaltene Danke: 5

Win XP
Delphi 7; Delphi 2005
BeitragVerfasst: Mo 28.11.11 15:09 
Hi, wenn es sich dabei um normale html Befehle handelt kannst du relativ angeben in welchem Verzeichnis geguckt werden soll :
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
./
farben.htm
./farben.htm
bilder/grafik.gif
./bilder/grafik.gif
../
../../../../woanders/datei.htm



de.selfhtml.org/html...in/referenzieren.htm

In deinem Fall wohl:

../deine.Datei

. gleiches Verzeichnis
.. ein Verzeichnis zurueck
../../zwei Verzeichnisse Zurueck
shana-chan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Mo 28.11.11 15:17 
Dar Problem ist, dass ich mich hier befinde: res://C:\test\Project1.exe/HTML/index
ich möchte aber zu: C:\test\
mit ../ komme ich zu: res://C:\test\Project1.exe/
mit ../../ komme ich zu: res://C:\test\Project1.exe/
mit ../../../ komme ich auch zu: res://C:\test\Project1.exe/