GetOpenFileName 有问题。在调用 GetOpenFileName 方法之前,WriteData 正在工作。WriteData 有一个简单的文件检查程序:
ifstream inFile(FileName.c_str());
if (!inFile.is_open()) return false;
ofn 转储:
并且在调用 GetOpenFileName 后它总是错误的。但在调用 GetOpenFileName 之前它工作正常。
while (!lang->LoadLang(config->getLanguagePath()))
{
OPENFILENAME ofn = {0};
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = config->getLanguagePath();
ofn.lpstrFile[0] = '\0';
ofn.lpstrTitle = "Select the language file";
ofn.nMaxFile = 255;
ofn.lpstrFilter = "Language file\0*.lng\0";
ofn.nFilterIndex = 1;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileName(&ofn) == 0) return 0;
config->WriteData(KEY_LANG, ofn.lpstrFile);
}