// 取得应用程序路径
cstring getapppath()
{
char exepath[max_path];
cstring strdir, tmpdir;
memset(exepath, 0, max_path);
getmodulefilename(null, exepath, max_path);
tmpdir = exepath;
strdir = tmpdir.left(tmpdir.reversefind(//));
return strdir;
}
// 读取xs.ini下的[info]下的一个名字叫"key"的相应的值
cstring getkey()
{
cstring strret;
char inivalue[100], filename[max_path];
memset(inivalue, 0, 100);
memset(filename, 0, max_path);
sprintf(filename, "%s//ini//xs.ini", getapppath());
getprivateprofilestring("info",
"key",
"",
inivalue,
sizeof(inivalue),
filename);
strret = inivalue;
return strret;
}
// 设置xs.ini下的[info]下的一个名字叫"key"的相应的值
void setkey(int key)
{
cstring strret;
char filename[max_path], ckey[10];
memset(ckey, 0, 10);
memset(filename, 0, max_path);
sprintf(filename, "%s//ini//xs.ini", getapppath());
sprintf(ckey, "%d", key);
writeprivateprofilestring("info", "key", ckey, filename);
}