Gets the current path
CString Szcurpath (_t (""));
GetModuleFileName (Null,szcurpath.getbuffer (MAX_PATH), MAX_PATH);
Szcurpath.releasebuffer ();
G_szcurpath = Szcurpath.left (Szcurpath.reversefind (' \ ") + 1);
The settings file
G_szsettingpath = G_szcurpath + _t ("Setting.ini") under the current path;
CFileFind find;
if (!find. FindFile (G_szsettingpath)) Makeresource (Idr_setting,g_szsettingpath);
Find. Close ();
BOOL Makeresource (int nID, CString szpathname)
{
hrsrc hsrc = FindResource (Null,makeintresource (NID), _t (" Owner_data "));
if (hsrc = NULL) return false;
Hglobal hglobal = LoadResource (NULL,HSRC);
if (hglobal = NULL) return false;
LPVOID LP = Lockresource (HGLOBAL);
DWORD dwsize = Sizeofresource (NULL,HSRC);
CFile file;
if (file. Open (szpathname,cfile::modecreate| Cfile::modewrite))
{
file. Write (lp,dwsize);
File. Close ();
}
FreeResource (hglobal);
return true;
}
CString szsection = _t ("Setting");
CString szkey =_t ("Langnum");
CString Szlang;
DWORD dwsize = m;
Nlangnum = M_cmblang.getcursel ();
Szlang.format (_t ("%d"), nlangnum);
WritePrivateProfileString (Szsection,szkey,szlang,g_szsettingpath);
Szlang.releasebuffer ();
CString szsection = _t ("Setting");
CString szkey =_t ("Langnum"), Szlang;
DWORD dwsize = m;
GetPrivateProfileString (szsection,szkey,_t (""), Szlang.getbuffer (dwsize), dwsize,g_szsettingpath);
SWSCANF (szlang,_t ("%d"), &nlangnum);
Szlang.releasebuffer ();
Double Cinifile::getinitvalue (LPCTSTR inifilename,lpctstr secname,lpctstr paraname)
{
WCHAR valbuf[128];
GetPrivateProfileString (secname,paraname,_t (""), valbuf,128,inifilename);
Return _ttof (VALBUF);
}
Short Cinifile::setinitvalue (LPCTSTR inifilename,lpctstr secname,lpctstr paraname,double Para)
{
CString Valstr;
Valstr.format (_t ("%.3f"), Para);
WritePrivateProfileString (secname,paraname,valstr,inifilename);
return 0;
}