Autor Beitrag
DSl1mSh4dy
Hält's aus hier
Beiträge: 15



BeitragVerfasst: So 11.04.10 20:05 
Sers, ich mal wieder ;-)

hier der Code:

ausblenden Delphi-Quelltext
1:
2:
   ProgrammOrdner := GetSpecialFolder(Handle, CSIDL_PERSONAL) + '\FarmiRechner 5.0\Produkte.ini';
   Ini := TIniFile.Create(ProgrammOrdner);


Hier der Code zur Funktion:

ausblenden 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:
function GetSpecialFolder(hWindow: HWND; Folder: Integer): String;
var
  pMalloc: IMalloc; 
  pidl: PItemIDList; 
  Path: PChar; 
begin 
  // get IMalloc interface pointer 
  if (SHGetMalloc(pMalloc) <> S_OK) then 
  begin 
    MessageBox(hWindow, 'Couldn''t get pointer to IMalloc interface.'
               'SHGetMalloc(pMalloc)'16); 
    Exit; 
  end

  // retrieve path 
  SHGetSpecialFolderLocation(hWindow, Folder, pidl); 
  GetMem(Path, MAX_PATH); 
  SHGetPathFromIDList(pidl, Path); 
  Result := Path; 
  FreeMem(Path); 

  // free memory allocated by SHGetSpecialFolderLocation 
  pMalloc.Free(pidl); 
end;



aber ich bekomme folgende Fehlermeldung:

First chance exception at $7660B727. Exception class EIniFileException with message 'Unable to write to C:\Users\<Benutzer>\Documents\<MeinProgramm>\Produkte.ini'. Process <MeinProgramm>.exe (3568)


Kann mir jemand sagen was da falsch is??

Gruß


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am So 11.04.2010 um 23:00
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19326
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 11.04.10 21:09 
Erstens erstellst du den Ordner gar nicht, dementsprechend kannst du auch nicht hineinschreiben.

Zweitens hat dein Programm dort nichts zu suchen, Einstellungen gehören in die Anwendungsdaten...
www.delphi-library.d...ewtopic.php?p=548600

Das ist tierisch nervig, dass einige Programme meinen den Benutzer ärgern zu müssen, indem der Dokumente-Ordner zugemüllt wird. :roll: