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
Printable View
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
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"?
lol im talking about having a C++ program read the info in the ini and using it to plug into somewhere else
>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.
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?Quote:
Originally Posted by GuardianBarak
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
::EDIT:: what would i need for the header? #include whatCode: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);
Err..whenever i do that it says something about the CString thing
"It says something about the CString thing" really doesn't give us much to go on. Post an actual error message.
"CString was not declaired in this scope" and, "CStringArray was not declaired in this scope"
how about just using GetPrivateProfileString() function?
How about posting some code.
>"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.
are the game u playing called Tibia? ;)
Ok.
MSDN contains a good description of the function.Code:#include <windows.h>
#include <string>
static int INI_BUFFER_SIZE = 512;
string section = "Section Name";
string key = "Key Name";
string def = "Value if Key is not Found";
string file = "Path to the INI file.";
char* temp = new char[INI_BUFFER_SIZE];
GetPrivateProfileString( section.c_str(), key.c_str(), def.c_str(), temp, INI_BUFFER_SIZE, file.c_str());
//temp contains the value from the ini file, do something with it.
delete [] temp;
You could allways write your own text parser to read the info.
thanks a ton Eber Kain! :p
Is this by any chance for Diablo II? (sorry for the off-topic post) If it is I think root's bot is open source now (I could be wrong) - have a look at that.Quote:
Originally Posted by GuardianBarak
yeah its for diablo ii ill go have a look at it