fleck
December 30th, 2002, 09:25 AM
hey, how can i detect if a GetPrivateProfileString() fails, i want to know if a section exists or not, i searched msdn, but didn' t get it, a failure value isn' t mentioned there, thanks
|
Click to See Complete Forum and Search --> : GetPrivateProfileString() fleck December 30th, 2002, 09:25 AM hey, how can i detect if a GetPrivateProfileString() fails, i want to know if a section exists or not, i searched msdn, but didn' t get it, a failure value isn' t mentioned there, thanks willchop December 30th, 2002, 09:38 AM My MSDN library doc states the default string parameter is copied to the return string parameter if nothing as read.. Maybe you can set the default string param to a string that you never expect to read from the initialization file. Then if your return string param has your string you will know nothing was read. lpDefault [in] Pointer to a null-terminated default string. If the lpKeyName key cannot be found in the initialization file, GetPrivateProfileString copies the default string to the lpReturnedString buffer. This parameter cannot be NULL. Remarks The GetPrivateProfileString function searches the specified initialization file for a key that matches the name specified by the lpKeyName parameter under the section heading specified by the lpAppName parameter. If it finds the key, the function copies the corresponding string to the buffer. If the key does not exist, the function copies the default character string specified by the lpDefault parameter. regards, willchop TheCPUWizard December 30th, 2002, 09:42 AM Are you actually looking for if the SECTION exists or simply the particular string you are looking for? If you are just tring to isolate if the Sting Exists, then WillChop's method is sufficient. If you are attempting to determine if the entire section is present, check first with a call to GetPrivateProfileSection() Hope this helps... fleck December 30th, 2002, 09:45 AM thanks, i mentioned that, but i wished it had an error value, your idea will do it, too codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved. |