![]() |
Re: In .ini ohne Adminrechte speichern?
Probieren geht über Studieren.
|
Re: In .ini ohne Adminrechte speichern?
So würdest Du ja direkt ins Anwendungsdatenverzeichnis speichern. Das ist aber so nicht gedacht, Du solltest dort ein Unterverzeichnis für Dein Programm erstellen und das dann nutzen.
|
Re: In .ini ohne Adminrechte speichern?
Zitat:
|
Re: In .ini ohne Adminrechte speichern?
Mach doch mal eine Kommandozeile auf (Start - Ausführen - cmd) und gib dort ein
Code:
Vermutlich wirst Du dort nur Verzeichnisse und keine Dateien finden.
dir "%APPDATA%"
|
Re: In .ini ohne Adminrechte speichern?
Irgendwie wird da noch nix und nirgendwo gespeichert :gruebel: Oh man... :wall:
|
Re: In .ini ohne Adminrechte speichern?
Zitat:
|
Re: In .ini ohne Adminrechte speichern?
Ich weiß ja nicht, wie und wo Du suchst.
|
Re: In .ini ohne Adminrechte speichern?
Ok es klappt jetzt alles :thumb:
Und wird das auch unter Vista gehen, was meinst du? |
Re: In .ini ohne Adminrechte speichern?
Eigentlich ist das ja von Microsoft genau so vorgesehen, sollte also auch unter Vista funktionieren.
|
Re: In .ini ohne Adminrechte speichern?
Zitat:
Delphi-Quellcode:
uses
ActiveX, ShlObj, IniFiles; const AppDataRootDir = '\AlexII'; AppDataProjectDir = '\Dein Projektname'; CSIDL_LOCAL_APPDATA = $001c; function GetSpecialFolder(aFolder: Integer): String; var pIdL: PItemIDList; Path: array [0..Max_Path] of Char; Allocator: IMalloc; begin // ItemIdList für den Ordner holen SHGetSpecialFolderLocation(0, aFolder, pIdL); // ItemIdList in String umwandeln lassen SHGetPathFromIDList(pIDL, Path); // Speicher wieder freigeben if Succeeded(SHGetMalloc (Allocator)) then Allocator.Free(pIdL); Result := Path; end; procedure TForm1.FormShow(Sender: TObject); var Ini: TIniFile; UserAppDataDir: String; begin UserAppDataDir := GetSpecialFolder(CSIDL_LOCAL_APPDATA); if FileExists(UserAppDataDir + AppDataRootDir + AppDataProjectDir + '\config.ini') then begin Ini := TIniFile.Create(UserAppDataDir + AppDataRootDir + AppDataProjectDir + '\config.ini'); try ComboBox1.ItemIndex := Ini.ReadInteger('Default', 'Channel', 0); TrackBar1.Position := Ini.ReadInteger('Default', 'Volume', 10); cbDirectConnection.Checked := Ini.ReadBool('Default', 'Proxy', True); ed_ProxyServer.Text := Ini.ReadString('Default', 'ProxyIP', ''); finally ini.free; end; end; end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); var Ini: TIniFile; UserAppDataDir: String; begin UserAppDataDir := GetSpecialFolder(CSIDL_LOCAL_APPDATA); ForceDirectories(UserAppDataDir + AppDataRootDir + AppDataProjectDir); Ini := TIniFile.Create(UserAppDataDir + AppDataRootDir + AppDataProjectDir + '\config.ini'); try Ini.WriteInteger('Default', 'Channel', ComboBox1.ItemIndex); Ini.WriteInteger('Default', 'Volume', TrackBar1.Position); Ini.WriteBool('Default', 'Proxy', cbDirectConnection.Checked); Ini.WriteString('Default', 'ProxyIP', ed_ProxyServer.Text); finally Ini.Free; end; Action := caFree; // Bringt nur etwas, wenn es nicht im Hauptformular steht end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:09 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz