hej allesammen.
Jeg har lavet en lille funktion der læser en fil og returnerer noget data, der sker dog en fejl i en lille test jeg har lavet:
Der er ingen grund til selv at parse din .ini fil. Der findes en "indbygget" funktionalitet til dette i Win32 API. See the snippets below.
GetPrivateProfileString
The GetPrivateProfileString function retrieves a string from the specified section in an initialization file. This function is provided for compatibility with 16-bit Windows-based applications. Win32-based applications should store initialization information in the registry.
DWORD GetPrivateProfileString(
LPCTSTR lpAppName, // points to section name
LPCTSTR lpKeyName, // points to key name
LPCTSTR lpDefault, // points to default string
LPTSTR lpReturnedString, // points to destination buffer
DWORD nSize, // size of destination buffer
LPCTSTR lpFileName // points to initialization filename
);
WritePrivateProfileString
The WritePrivateProfileString function copies a string into the specified section of the specified initialization file.
This function is provided for compatibility with 16-bit Windows-based applications. WIn32-based applications should store initialization information in the registry.
BOOL WritePrivateProfileString(
LPCTSTR lpAppName, // pointer to section name
LPCTSTR lpKeyName, // pointer to key name
LPCTSTR lpString, // pointer to string to add
LPCTSTR lpFileName // pointer to initialization filename
);