| Autor |
Beitrag |
Jakob Schöttl
      
Beiträge: 929
Erhaltene Danke: 1
Delphi 7 Professional
|
Verfasst: Do 26.01.06 09:18
Hi,
Ich habe Win98 und Delphi4. Ich habe ein Programm, das mit dem Objekt INIFile: TINIFile in die Datei "Einstellungen.ini" schreiben soll. Bei Windows98 funktioniert das auch super, aber nicht bei XP. Da kommt immer die Meldung: "Nach 'Einstellungen.ini' kann nicht geschrieben werden"
Vielleicht hat jemand eine Lösung oder Idee,
Danke im Voraus!
Jakob
|
|
Gausi
      
Beiträge: 8554
Erhaltene Danke: 481
Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
|
Verfasst: Do 26.01.06 09:24
In welchem Ordner soll denn die Ini gespeichert werden? Und hat der Anwender in diesem Verzeichnis auch Schreibrechte?
_________________ We are, we were and will not be.
|
|
Horst_H
      
Beiträge: 1654
Erhaltene Danke: 244
WIN10,PuppyLinux
FreePascal,Lazarus
|
Verfasst: Do 26.01.06 09:46
Hallo,
ist die Datei vielleicht read-only, dass passiert mir, wenn ich Dateien von einer CD kopiere
Gruss Horst
|
|
Kroko
      
Beiträge: 1284
W98 W2k WXP
Turbo D
|
Verfasst: Do 26.01.06 09:58
// GLASKUGEL AN
Ich vermute mal, Einstellungen.ini ist ohne Pfadangabe und wird daher im Windows-Verzeichnis gespeichert. Dies geht unter W98, unter WXP nur als Admin -> daher Delphi-Quelltext 1:
| MyIniFileName := ExtractFilePath(Application.ExeName)+'Einstellungen.ini'; |
//GLASKUGEL AUS
_________________ Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
|
|
galagher
      
Beiträge: 2562
Erhaltene Danke: 46
Windows 10 Home
Delphi 10.1 Starter, Lazarus 2.0.6
|
Verfasst: Fr 27.01.06 20:18
Kroko hat folgendes geschrieben: | Delphi-Quelltext 1:
| MyIniFileName := ExtractFilePath(Application.ExeName)+'Einstellungen.ini'; | |
Aber genau das soll (kann) man ja auch nicht machen - normalerweise hat auch nur der Admin Schreibrechte im Programmordner!
Daher verwende den Benutzerdaten-Ordner mit "appdata" - ich hab da was Feines:
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: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91:
| const CSIDL_ADMINTOOLS = $00000030; CSIDL_CDBURN_AREA = $0000003b; CSIDL_COMMON_ADMINTOOLS = $0000002f; CSIDL_COMMON_APPDATA = $00000023; CSIDL_COMMON_DOCUMENTS = $0000002e; CSIDL_COMMON_MUSIC = $00000035; CSIDL_COMMON_PICTURES = $00000036; CSIDL_COMMON_TEMPLATES = $0000002d; CSIDL_COMMON_VIDEO = $00000037; CSIDL_MYPICTURES = $00000027; CSIDL_PROFILE = $00000028; CSIDL_PROFILES = $0000003e; CSIDL_PROGRAM_FILES = $00000026; CSIDL_PROGRAM_FILES_COMMON = $0000002b; CSIDL_SYSTEM = $00000025; CSIDL_WINDOWS = $00000024; function GetShellDir(ShellDir: TShellDir): String; var pidl: PItemIDList; Path: array[0..max_path] of char; begin if ShellDir = favorits then SHGetSpecialFolderLocation(Application.Handle, CSIDL_FAVORITES, pidl);
if ShellDir = programs then SHGetSpecialFolderLocation(Application.Handle, CSIDL_PROGRAMS, pidl);
if ShellDir = startmenu then SHGetSpecialFolderLocation(Application.Handle, CSIDL_STARTMENU, pidl);
if (ShellDir = documents) or (ShellDir = recent) then SHGetSpecialFolderLocation(Application.Handle, CSIDL_RECENT, pidl);
if ShellDir = allusersstartmenu then SHGetSpecialFolderLocation(Application.Handle, CSIDL_COMMON_STARTUP, pidl);
if ShellDir = allusersappdata then SHGetSpecialFolderLocation(Application.Handle, CSIDL_COMMON_APPDATA, pidl);
if ShellDir = commondocuments then SHGetSpecialFolderLocation(Application.Handle, CSIDL_COMMON_DOCUMENTS, pidl);
if (ShellDir = personal) or (ShellDir = ownfiles) then SHGetSpecialFolderLocation(Application.Handle, CSIDL_PERSONAL, pidl);
if ShellDir = autostart then SHGetSpecialFolderLocation(Application.Handle, CSIDL_STARTUP, pidl);
if ShellDir = sendto then SHGetSpecialFolderLocation(Application.Handle, CSIDL_SENDTO, pidl);
if ShellDir = printers then SHGetSpecialFolderLocation(Application.Handle, CSIDL_PRINTERS, pidl);
if ShellDir = printhood then SHGetSpecialFolderLocation(Application.Handle, CSIDL_PRINTHOOD, pidl);
if ShellDir = desktop then SHGetSpecialFolderLocation(Application.Handle, CSIDL_DESKTOPDIRECTORY, pidl);
if ShellDir = tempnet then SHGetSpecialFolderLocation(Application.Handle, CSIDL_INTERNET_CACHE, pidl);
if ShellDir = cookies then SHGetSpecialFolderLocation(Application.Handle, CSIDL_COOKIES, pidl);
if ShellDir = history then SHGetSpecialFolderLocation(Application.Handle, CSIDL_HISTORY, pidl);
if ShellDir = appdata then SHGetSpecialFolderLocation(Application.Handle, CSIDL_APPDATA, pidl);
if ShellDir = templates then SHGetSpecialFolderLocation(Application.Handle, CSIDL_TEMPLATES, pidl);
if ShellDir = fonts then SHGetSpecialFolderLocation(Application.Handle, CSIDL_FONTS, pidl);
if ShellDir = nethood then SHGetSpecialFolderLocation(Application.Handle, CSIDL_NETHOOD, pidl);
if ShellDir = network then SHGetSpecialFolderLocation(Application.Handle, CSIDL_NETWORK, pidl);
SHGetPathFromIDList(pidl, Path);
Result := IncludeTrailingPathDelimiter(Path); end; |
_________________ gedunstig war's - und fahle wornen zerschellten karsig im gestrock. oh graus, es gloomt der jabberwock - und die graisligen gulpen nurmen!
|
|
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Fr 27.01.06 21:53
Warum so umständlich?
Delphi-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:
| function GetShellFolder(CSIDL: integer): string; var pidl : PItemIdList; FolderPath : string; SystemFolder : Integer; Malloc : IMalloc; begin Malloc := nil; FolderPath := ''; SHGetMalloc(Malloc); if Malloc = nil then begin Result := FolderPath; Exit; end; try SystemFolder := CSIDL; if SUCCEEDED(SHGetSpecialFolderLocation(0, SystemFolder, pidl)) then begin SetLength(FolderPath, max_path); if SHGetPathFromIDList(pidl, PChar(FolderPath)) then begin SetLength(FolderPath, length(PChar(FolderPath))); end; end; Result := FolderPath; finally Malloc.Free(pidl); end; end; |
|
|
Jakob Schöttl 
      
Beiträge: 929
Erhaltene Danke: 1
Delphi 7 Professional
|
Verfasst: Mo 13.02.06 15:19
Titel: Bin wieder da
Hi,
Ich hab diese Seite ganz vergessen, da ich das Programm sozusagen aufgegeben habe. Danke für eure Ideen.
Den ort, wo er die Datei speichert hab ich schon richtig ausgewählt, danke Kroko, da hab ich mich davor auch schon gewundert.
Das von Horst_H könnte sein, ich kopiere es zwar nicht von der CD aber von USB-FlashDisk.
Ob ich Schreibrechte hab weiß ich nicht genau. Eigentlich schon, weil andere Programme in C:\Windows\Programme dürfen das ja auch, oder.
Aber ich glaub ich hab trotzdem keine Schreibrechte in dem Ordner, weil unter eigenschaften die CheckBox "Schreibgeschützt" .Checked = True. Die Checkbox ist aber seltsamerweise grau in der Mitte und nicht weiß wie normal.
Ich mache Checkbox.Checked := False;
Wenn ich den Eigenschaftendialog mit OK schließe und dann wieder öffne, dann ist die Checkbox.Checked aber wieder auf True.
Das gilt sowohl für den Ordner, wie auch für die INIDatei selbst.
Vielleicht schreibt wieder jemand *hoff*
Jakob
|
|
galagher
      
Beiträge: 2562
Erhaltene Danke: 46
Windows 10 Home
Delphi 10.1 Starter, Lazarus 2.0.6
|
Verfasst: Do 16.02.06 17:23
Titel: Re: Bin wieder da
bokaj hat folgendes geschrieben: | | Ob ich Schreibrechte hab weiß ich nicht genau. Eigentlich schon, weil andere Programme in C:\Windows\Programme dürfen das ja auch, oder. |
Ob Schreibrechte oder nicht, kanst du herausfinden:
www.luckie-online.de...CheckFileAccess.html
_________________ gedunstig war's - und fahle wornen zerschellten karsig im gestrock. oh graus, es gloomt der jabberwock - und die graisligen gulpen nurmen!
|
|
|