Getting values from ini file

I'm using this class: http://www.codeproject.com/Articles/10809/A-Small-Class-to-Read-INI-File

The format of my ini file:
1
2
3
4
5
[TPCoordinate]
TP1_X=-1130
TP1_Y=543
TP2_X=591
TP2_Y=273


How do I make it so that it can read that integer and then put it into a form textbox? I'm using a button to load those coordinates into a textbox.
Last edited on
How do I make it so that it can read that integer


Try this to load it from the file:
1
2
3
4
5
6
CIniReader reader("Yourfilename");

int X = reader.ReadInteger("TPCoordinate", "TP1_X", -1 );

if (X != -1) // value was there
  // use X 


and then put it into a form textbox? I'm using a button to load those coordinates into a textbox.


This depends what are you using - C++/CLI or Win API or...
It turns out, it was working, but my file path was wrong.

1
2
3
4
5
6
7
8
9
10
11
	
        CIniReader iniReader(".\\settings.ini");
	CIniWriter iniWriter(".\\settings.ini");

	if (dwTPC == 1)
	{
		this->TP1_X->Text = iniReader.ReadInteger("TPCoordinate", "TP1_X", 0).ToString();
		this->TP1_Y->Text = iniReader.ReadInteger("TPCoordinate", "TP1_Y", 0).ToString();
		this->TP2_X->Text = iniReader.ReadInteger("TPCoordinate", "TP2_X", 0).ToString();
		this->TP2_Y->Text = iniReader.ReadInteger("TPCoordinate", "TP2_Y", 0).ToString();
	}

Topic archived. No new replies allowed.