EDN Admin
Well-known member
Dears All,
I have problem with reading from ini file. My code is as follows, but it has Error with GetPrivateProfileInt. It cannot read and the error is :
error C2664: GetPrivateProfileIntW : cannot convert parameter 1 from const char [9] to LPCWSTR<br/>
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Please Help
--------------code-------------
void ReadIniFile(const char* inifile)<br/>
{<br/>
printf("Reading: %sn", inifile);<br/>
char entry[128];<br/>
res=GetPrivateProfileInt("settings", "resolution", 256, inifile); /* resolusi paparan */<br/>
hres=res/2; <br/>
GetPrivateProfileString("settings", "brightness", "2.5", entry, 128, inifile);<br/>
brightness=atof(entry);<br/>
step=GetPrivateProfileInt("settings", "step", 2, inifile); /* untuk jeda masa bagi rendering */<br/>
GetPrivateProfileString("settings", "near", "0.1", entry, 128, inifile); /* ketipan viewplane */<br/>
near_plane=atof(entry);<br/>
GetPrivateProfileString("settings", "far", "40.0", entry, 128, inifile);<br/>
far_plane=atof(entry);<br/>
double angle=GetPrivateProfileInt("settings", "smooth_angle", 2, inifile); /* sudut pengujian bagi normal segitiga */<br/>
cos_angle=cos(angle * 3.1415927 / 180.0); /* darjah->radian */<br/>
GetPrivateProfileString("settings", "stop_at", "0.0001", entry, 128, inifile);<br/>
converged=atof(entry);/* nilai penumpuan */<br/>
<br/>
View the full article
I have problem with reading from ini file. My code is as follows, but it has Error with GetPrivateProfileInt. It cannot read and the error is :
error C2664: GetPrivateProfileIntW : cannot convert parameter 1 from const char [9] to LPCWSTR<br/>
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Please Help
--------------code-------------
void ReadIniFile(const char* inifile)<br/>
{<br/>
printf("Reading: %sn", inifile);<br/>
char entry[128];<br/>
res=GetPrivateProfileInt("settings", "resolution", 256, inifile); /* resolusi paparan */<br/>
hres=res/2; <br/>
GetPrivateProfileString("settings", "brightness", "2.5", entry, 128, inifile);<br/>
brightness=atof(entry);<br/>
step=GetPrivateProfileInt("settings", "step", 2, inifile); /* untuk jeda masa bagi rendering */<br/>
GetPrivateProfileString("settings", "near", "0.1", entry, 128, inifile); /* ketipan viewplane */<br/>
near_plane=atof(entry);<br/>
GetPrivateProfileString("settings", "far", "40.0", entry, 128, inifile);<br/>
far_plane=atof(entry);<br/>
double angle=GetPrivateProfileInt("settings", "smooth_angle", 2, inifile); /* sudut pengujian bagi normal segitiga */<br/>
cos_angle=cos(angle * 3.1415927 / 180.0); /* darjah->radian */<br/>
GetPrivateProfileString("settings", "stop_at", "0.0001", entry, 128, inifile);<br/>
converged=atof(entry);/* nilai penumpuan */<br/>
<br/>
View the full article