December 30th, 2002, 08: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
December 30th, 2002, 08: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.
[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.
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.
December 30th, 2002, 08: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...
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code
outside of [code] ... [/code]
tags. See here
* How NOT
to post a question here
* Of course you read this
carefully before you posted
* Need homework help? Read this first
December 30th, 2002, 08:45 AM
thanks, i mentioned that, but i wished it had an error value, your idea will do it, too
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.