Thread: How do i read from ini?

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    19

    Angry How do i read from ini?

    anyone help me out here? I need to know how to read from a ini file i read other sites and they all dont work

  2. #2
    Compulsive Liar Robc's Avatar
    Join Date
    Jul 2004
    Posts
    149
    An INI file is simply a text file with [headers] followed by name/attribute pairs. There's shouldn't be any problem with opening and reading such a file. Can you be more specific than "they all don't work"?

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    19
    lol im talking about having a C++ program read the info in the ini and using it to plug into somewhere else

  4. #4
    Compulsive Liar Robc's Avatar
    Join Date
    Jul 2004
    Posts
    149
    >im talking about having a C++ program read the info in the ini
    Okay, that's equally trivial privided your data is valid.

    >and using it to plug into somewhere else
    To "plug" into what, how? I'll need details if I'm going to help you or send you somewhere that you can be helped if I can't.

  5. #5
    Registered User
    Join Date
    Jul 2004
    Posts
    19
    im making a bot for a game i play and i need the thing to read the ini file and get the AccountName then put it in then get AccountPass and put it in then the CharacterLocation..

  6. #6
    Compulsive Liar Robc's Avatar
    Join Date
    Jul 2004
    Posts
    149
    Quote Originally Posted by GuardianBarak
    im making a bot for a game i play and i need the thing to read the ini file and get the AccountName then put it in then get AccountPass and put it in then the CharacterLocation..
    That's much more descriptive, thank you. Now what have you been trying that doesn't work?

  7. #7
    Registered User
    Join Date
    Jul 2004
    Posts
    19
    i appoligize for not being descriptive, i've been looking at sites and such for programming and they show ways of reading it but they dont work...heres one example of what they showed me
    Code:
    BOOL Get(LPCTSTR pszSection, LPCTSTR pszEntry, int &nVal);
    BOOL Set(LPCTSTR pszSection, LPCTSTR pszEntry, int nVal);
    BOOL Set(LPCTSTR pszSection, LPCTSTR pszEntry, COLORREF rgb);
    BOOL Get(LPCTSTR pszSection, LPCTSTR pszEntry, COLORREF &rgb);
    ::EDIT:: what would i need for the header? #include what
    Last edited by GuardianBarak; 07-16-2004 at 08:18 PM.

  8. #8
    Compulsive Liar Robc's Avatar
    Join Date
    Jul 2004
    Posts
    149
    It looks like you're trying to use the CIniFile class. You should be able to get it here.

  9. #9
    Registered User
    Join Date
    Jul 2004
    Posts
    19
    Err..whenever i do that it says something about the CString thing

  10. #10
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    "It says something about the CString thing" really doesn't give us much to go on. Post an actual error message.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  11. #11
    Registered User
    Join Date
    Jul 2004
    Posts
    19
    "CString was not declaired in this scope" and, "CStringArray was not declaired in this scope"

  12. #12
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    how about just using GetPrivateProfileString() function?

  13. #13
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    How about posting some code.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  14. #14
    Compulsive Liar Robc's Avatar
    Join Date
    Jul 2004
    Posts
    149
    >"CString was not declaired in this scope" and, "CStringArray was not declaired in this scope"
    You realize that you're trying to work with MFC, right? I get the impression that you have no idea what MFC is or how to use it. Maybe a good book is in order before you go any further.

  15. #15
    Banned
    Join Date
    May 2004
    Posts
    55
    are the game u playing called Tibia?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What Would You Use To Read User Input?
    By djwicks in forum C Programming
    Replies: 11
    Last Post: 04-05-2005, 03:32 PM
  2. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  3. I am lost on how to read from file and output to file?
    By vicvic2477 in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2005, 11:52 AM
  4. Read Array pro!!Plz help!!
    By Supra in forum C Programming
    Replies: 2
    Last Post: 03-04-2002, 03:49 PM
  5. Help! Can't read decimal number
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 09-07-2001, 02:09 AM