GetPrivateProfileString()
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: GetPrivateProfileString()

  1. #1
    Join Date
    Aug 2002
    Location
    germany
    Posts
    112

    GetPrivateProfileString()

    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

  2. #2
    Join Date
    Aug 2002
    Location
    VA, USA
    Posts
    137
    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

  3. #3
    Join Date
    Mar 2002
    Location
    NY, USA
    Posts
    12,097
    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!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  4. #4
    Join Date
    Aug 2002
    Location
    germany
    Posts
    112

    gpps()

    thanks, i mentioned that, but i wished it had an error value, your idea will do it, too

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center