|
You last visited: Today at 04:28
Advertisement
[C++]IniRead Problem?
Discussion on [C++]IniRead Problem? within the C/C++ forum part of the Coders Den category.
05/22/2014, 19:34
|
#1
|
elite*gold: 0
Join Date: Apr 2014
Posts: 28
Received Thanks: 0
|
[C++]IniRead Problem?
Hi guys  I have a problem to read the ini file :
PHP Code:
//ini.cpp
ReadIni::ReadIni(char *szFileName)
{
memset(m_szFileName, 0x00, 255);
memcpy(m_szFileName, szFileName, strlen(szFileName));
}
char* ReadIni::String(char *szSection, char *szKey, const char *szDefaultValue)
{
char *szResult = new char[255];
memset(szResult, 0x00, 255);
GetPrivateProfileString(szSection, szKey, szDefaultValue, szResult, 255, m_szFileName);
return szResult;
}
And ..
PHP Code:
//ini.h
class ReadIni
{
private:
char m_szFileName[255];
public:
ReadIni(char *szFileName);
char *String(char *szSection, char *szKey, const char* szDefaultValue);
};
In the main, when i put this code :
PHP Code:
ReadIni *Read = new ReadIni(".\\config.ini");
std::string read = Read->String("Section","Key","Defalut");
std::cout<<read<<std::endl;
The console write the default value : "Defalut", how i to do for the console write the value that is in the config?
|
|
|
05/23/2014, 02:54
|
#2
|
elite*gold: 0
Join Date: May 2013
Posts: 101
Received Thanks: 42
|
Do you want to get the file config.ini in the parent directory ?
If so :
Code:
ReadIni reader("..\\config.ini");
You forgot a dot ( . ).
|
|
|
05/23/2014, 14:34
|
#3
|
elite*gold: 0
Join Date: Apr 2014
Posts: 28
Received Thanks: 0
|
Thanks for reply, but It's Same xD, the console write the default value : "Defalut"
|
|
|
05/23/2014, 14:53
|
#4
|
elite*gold: 110
Join Date: Jun 2013
Posts: 599
Received Thanks: 510
|
Is the config.ini in your folder? If yes, remove the ".\\".
And i would rename the function called "String" into something like ReadString ( just my opinion ).
If it still fails you could use the function GetLastError to receive the error code.
|
|
|
05/23/2014, 15:42
|
#5
|
elite*gold: 0
Join Date: Apr 2014
Posts: 28
Received Thanks: 0
|
The file config is in the folder, and i try with "config.ini" but not work D:
|
|
|
05/23/2014, 16:19
|
#6
|
elite*gold: 110
Join Date: Jun 2013
Posts: 599
Received Thanks: 510
|
Could you post your Ini-File here?
|
|
|
05/23/2014, 17:11
|
#7
|
elite*gold: 0
Join Date: Apr 2014
Posts: 28
Received Thanks: 0
|
look up
|
|
|
05/24/2014, 09:25
|
#8
|
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
|
1.: ".\\config.ini" is totally correct.
2.: your working dir is not the path of the compiled exe file if you run it through the visual studio debugger! ".\\" will be the project path instead.
3.: use strcpy(_s) in your constructor.
4.: your ini should look like this:
|
|
|
05/24/2014, 15:04
|
#9
|
elite*gold: 0
Join Date: Apr 2014
Posts: 28
Received Thanks: 0
|
Thanks all guys for reply i solved  I want to start software by admin xD And no by Vs
|
|
|
 |
Similar Threads
|
IniRead - kleines Problem
09/14/2011 - AutoIt - 2 Replies
Hey Com,
habe gerade ein kleines Problem mit AutoIt und mit SuFu nichts brauchbares/hilfreiches gefunden...
AutoIT:
IniWrite(@ScriptDir & "/Settings.ini","Koordinaten", GuiCtrlRead($SaveName),GuiCtrlRead($XKoord) & "|" & GuiCtrlRead($YKoord) & "|" & GuiCtrlRead($ZKoord))
Ini:
|
Problem mit IniRead und Hide/Show.
01/28/2011 - AutoIt - 4 Replies
Ich habe mich seit einer langen seit mal wieder an Autoit gesetzt und auch gleich etwas ordentliches versucht...
nur bin ich nach kurzer Zeit schon auf die ersten Problemchen gestoßen...
vorerst einmal der Script:
|
IniRead problem
08/13/2010 - AutoIt - 7 Replies
Hab mich weiter durch etliche tuts gequält auch in nem autoit forum gefragt aber so richtig bekommt keiner das hin
HotKeySet("{ESC}","EXITT")
$ini = "config.ini"
$iniread = IniRead($ini,"Nutzung","ja/nein&quo t;,"ja","NotFound")
If $iniread = "ja" Then
$name = IniRead($ini,"Login","Name")
$pw = IniRead($ini,"Login","PW")
|
IniRead~Input Problem
05/02/2010 - AutoIt - 2 Replies
mein 2ter thread,weil ich grad beim letzten Schritt daran verzweifel
Mein Ziel ist es die gewuenschte Realmlist abzuspeichern in der .ini datei und auf Buttondruck wieder hervorzurufen
und das 3 mal (sprich 3 Favoriten)
hier der Script
Es funktioniert alles soweit auch das speichern der Favoriten,nur das Aufrufen funktioniert nicht.
|
All times are GMT +1. The time now is 04:28.
|
|