Autor Beitrag
Brothy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 11.04.06 16:05 
hi,
also ich wollte, aus einstellungen, die gespeichert werden wieder den Pfad einer DirectoryListbox laden dazu benutze ich:
DirectoryListbox1.Drive := config.ReadString('letzten ordner','pfad','C:\')[1];
Directorylistbox1.Directory := config.ReadString('letzten ordner','pfad','C:\');

Dabei zeigt er mir ne Fehlermeldung beim ausführen an.
Nun möchte ich euch bitten mir ne lösung zu geben.
mfg Brothy
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Di 11.04.06 16:07 
user profile iconBrothy hat folgendes geschrieben:
Dabei zeigt er mir ne Fehlermeldung beim ausführen an.


Und welche? Wär vielleicht nicht schlecht, wenn du die mit angeben würdest :roll:

AXMD
Brothy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 11.04.06 16:20 
hi,
sorry dachte hab se mit angegeben ^^
hier ist sie:
"Acces violatio at address blablabla in module 'Project1.exe'. Read of address blablabla."
Blablabla sind hald die speicheraddressen.
Mfg Brothy
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 11.04.06 16:27 
Moin und :welcome: im Forum!

ausblenden Delphi-Quelltext
1:
2:
DirectoryListbox1.Drive := config.ReadString('letzten ordner','pfad','C:\')[1];
Directorylistbox1.Directory := config.ReadString('letzten ordner','pfad','C:\');

Du greifst da auf Stringteile zu, von denen du an dieser Stelle gar nicht weißt, ob es sie denn auch gibt. ;) Was passiert wohl, wenn der String leer ist :arrow: Exception! :D

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Brothy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 11.04.06 16:35 
hi,
ja wenn es den string nicht gibt dann verwendet er doch C:\ oder ??? (hab ich da was falsch verstanden)
ausser dem gibts in diesem bestimmten fall den string schon! (ja es ist halt dann nicht möglich auf jedem pc laufen zu lassen) aber daran kanns ja dann nicht liegen oder? Und wenn er gespeichert wird, wird auch ein gültiger pfad gespeichert ...
Ausserdem kommt der fehler auch wenn ich nur die 2. zeile benutze!
Villeicht hilft das weiter.
Mfg Brothy
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 11.04.06 16:43 
Moin!

user profile iconBrothy hat folgendes geschrieben:
ja wenn es den string nicht gibt dann verwendet er doch C:\ oder ??? (hab ich da was falsch verstanden)

Wenn es den Schlüssel nicht gibt, aber wenn der Wert leer ist, kriegst du trotzdem einen Leerstring zurück. ;)

Dann zeig doch mal die ganze Prozedur (vermute, du erzeugst das TIniFile-Objekt nicht korrekt).

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Brothy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 11.04.06 16:44 
hi
da haste se:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.Panel1Click(Sender: TObject);
begin
try
  config := TIniFile.create(ExtractFilePath(ParamStr(0))+
                   'config.ini');
  DirectoryListbox1.Drive := config.ReadString('letzten ordner','pfad','C:\')[1];
  Directorylistbox1.Directory := config.ReadString('letzten ordner','pfad','C:\');
finally
  config.Free;
end;
end;

Mfg Brothy
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 11.04.06 16:47 
Moin!

Mach doch mal statt:
ausblenden Delphi-Quelltext
1:
2:
DirectoryListbox1.Drive := config.ReadString('letzten ordner','drive','C:\')[1];
Directorylistbox1.Directory := config.ReadString('letzten ordner','pfad','C:\');

das hier:
ausblenden Delphi-Quelltext
1:
2:
ShowMessage(config.ReadString('letzten ordner','drive','C:\')[1]);
ShowMessage(config.ReadString('letzten ordner','pfad','C:\'));

Was passiert?

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Brothy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 11.04.06 16:49 
ja die kleinen helfertricks ;)
naja er zeigt die korrekten pfäde an ...
E
bzw
E:\delphi

kann es vielleicht daran liegen, dass DirectoryListbox1.Drive nen char sein muss und er nicht es richtige bekommt?
ALlerdings müsste dann aber ja:
Directorylistbox1.Directory := config.ReadString('letzten ordner','pfad','C:\');
alleine funktionieren, das tuts aber nicht!
Mfg Brothy


Zuletzt bearbeitet von Brothy am Di 11.04.06 16:53, insgesamt 1-mal bearbeitet
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 11.04.06 16:52 
Moin!

Liegt also nicht am Ini-File-Zugriff. Sicher, dass du .Drive einen Char zuweisen darfst? :gruebel:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Brothy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 11.04.06 16:54 
.drive muss en char sein sonst beim string mault delphi rum dass es en char sein muss!
Mfg Brothy
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 11.04.06 16:58 
Moin!

Lass dir dochmal mit ShowMessage "im Betrieb" die Eigenschaften .Drive und .Directory ausgeben. Evtl. darf der Pfad nur relativ sein (-> deshalb dann auch .Drive)?

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Brothy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 11.04.06 16:59 
user profile iconNarses hat folgendes geschrieben:
Moin!

Wenn es den Schlüssel nicht gibt, aber wenn der Wert leer ist, kriegst du trotzdem einen Leerstring zurück. ;)



Ja stimmt, aber wenn keiner in der ini rumpfuscht manuell steht da nie en leerer Wert drinne ;) aber ich muss dir zu stimmen.
Mfg Brothy
Brothy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 11.04.06 17:01 
user profile iconNarses hat folgendes geschrieben:
Moin!

Lass dir dochmal mit ShowMessage "im Betrieb" die Eigenschaften .Drive und .Directory ausgeben. Evtl. darf der Pfad nur relativ sein (-> deshalb dann auch .Drive)?

cu
Narses


hab ich mir au am anfang gedach aber ich speicher mit .directory in die ini und da steht
[letzten ordner]
öffnen=1
pfad=E:\VDub
drive=E

/ende ini

pfad wird mit .directory gespeichert. Aber ich probiers nomal und antwort mit edit

//edit
.Directory ist nicht relativ angegeben sondern mit Drive !! z.b. E:\Delphi
.Drive wird mit E zurückgegeben
Mfg Brothy
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 11.04.06 17:07 
Moin!

Lass nochmal die Exception aufknallen, mit Strg+C rauskopieren und hier reinstellen. In welcher Zeile wird der Fehler angegeben? Diese und die drei darüber mal zeigen, bitte. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Brothy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 11.04.06 17:12 
tach,
weiss jetzt net genau was de meinst, aber hier die zeilen die er markiert wenn der fehler kommt (nur letzte is blau markiert!):

begin
Application.Initialize;
Application.Title := 'Project1';
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

wie gesagt beim "end." kommt der fehler

//edit
wenn ich bei der fehlermeldung strg+c mach kopiert er:
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EPrivilege with message 'Privileged instruction'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------


mfg Brothy


Zuletzt bearbeitet von Brothy am Di 11.04.06 17:23, insgesamt 2-mal bearbeitet
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 11.04.06 17:14 
Moin!

Kommt die Exception direkt nach dem Starten oder machst du irgend was und dann erst? Wenn ja, was (Prozedur)?

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Brothy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 11.04.06 17:18 
hi,
ja die kommt halt wenn ich aufs panel drück mit der procedur die die werte setzen sollte.Diese procedure findeste ja oben!
Mfg Brothy
P.S.:
Normal sollte es ja in der Form.create sein, aber damit der fehler net glei am start kommt und zum unterscheiden bei welcher procedure er kommt hab ichs so gemacht...
Brothy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 11.04.06 17:52 
hi,
hab grad was entdeckt, also wenn ich die ini lösch und es dann mach, dann gehts, sonst kommt eben der fehler.
Also muss es doch am zugriff auf die Datei liegen oder an den werten die diese wiedergibt.
Villeicht hilft des weiter!
// EDIT
WICHTIG!!!!
Hab das Problem gefunden !!!!!
Der Befehl darf nicht in die
ausblenden Delphi-Quelltext
1:
2:
3:
Try
finally
end;

schleife rein !!!!!
wenn er da drin is gehts net !!!!
Code sieht dann wie folgt aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.FormCreate(Sender: TObject);
var ts : string;
    tc : char;
begin
try
config := TIniFile.create(ExtractFilePath(ParamStr(0))+
    'config.ini');
    tc :=  config.ReadString('letzten ordner','drive','C:\')[1];
    ts := config.ReadString('letzten ordner','pfad','C:\');
finally
config.Free;
end;
DriveComboBox1.Drive := tc  ;
DirectoryListbox1.Drive := tc;
Directorylistbox1.Directory := ts;
end;


Mfg Brothy