CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 1999
    Location
    NY
    Posts
    28

    reading an INI file (GetPrivateProfileString)

    Im trying to read an INI file, but it keeps coming up with the default entry.. I know the ini file exists and the key and section im looking for exist.. is there something wrong with this function?

    char *ReadINIVal(const char* Section, const char* Key, const char* INIFN)
    {
    char buffer[2000];
    char er[100] = "Could Not Read Initialization Value: ";
    BOOL ret;

    ret = GetPrivateProfileString(Section, Key, "ER_NF", buffer, 2000, INIFN);
    if ((ret == 5) & (strcmp(buffer, "ER_NF")==0)) MessageBox(MainhWnd, strcat(er, Key), INIFN, MB_OK|MB_ICONEXCLAMATION );
    return(buffer);
    }



    any help would be greatly appreciated.. Thanks in advance

    Illusioned

  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: reading an INI file (GetPrivateProfileString)

    you posted only parts of your code, but the following line looks fishy to me:

    if ((ret == 5) & (strcmp(buffer, "ER_NF")==0))



    i'd add a second "&" as in

    if ((ret == 5) && (strcmp(buffer, "ER_NF")==0))



    you are doing a bitwise AND


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured