Autor Beitrag
Biarchiv
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: So 19.01.03 16:46 
Hallo,

Habe folgendes Problem:
Ich will bei meiner EXE Datei ParamStr(0) ein Byte auslesen und wenn
das Byte 01 ist stattessen einen FilePath in einen String setzen.

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
 
var
 Buffer2: Array[0..MAX_PATH+1] of Char;
 fsTo: TFileStream;
 ExtPath : integer;
 Buffer : string;


begin
  fsTo := TFileStream.create(ParamStr(0), fmOpenRead or fmShareDenyWrite);
  fsTo.Seek(176, soFromBeginning); // Server-EXE überspringen
  fsTo.Read(ExtPath, 1);
  fsTo.Free;
  If (ExtPath = $00) then exit;
  If (ExtPath = $01) then Buffer := InttoStr(GetTempPath(MAX_PATH+1,Buffer2));
  If (ExtPath = $02) then Buffer := IntToStr(GetSystemDirectory(Buffer2, MAX_PATH+1));
  If (ExtPath = $03) then Buffer := ExtractFilePath(ParamStr(0));
  If (ExtPath = $04) then Buffer := IntToStr(GetWindowsDirectory(Buffer2, MAX_PATH+1));
 Buffer := IncludeTrailingPathDelimiter(Buffer); // '\' anhängen



Wie kann ich das da richtig Übernehmen da wenn ich Showmessage probiere kommen
statt 01, 02 ,... nur wirre Zahlen?

Er versteht ExtPath nicht richtig.
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: So 19.01.03 17:27 
1. Deklariere mal ExtPath als Byte, wenn du schon nur 1 Byte ausliest.
2. Was soll denn in Buffer nun stehen?
Zitat:
InttoStr(GetTempPath(MAX_PATH+1,Buffer2));

Hier steht danach in Buffer die Länge des TempPath, aber nicht dessen Name. Denn der steht in Buffer2. Dasselbe gilt für GetSystemDirectory und GetWindowsDirectory.

_________________
Ist Zeit wirklich Geld?