在这个例子中它编译成工作代码,但是如果我在它周围放置更复杂的东西,程序就会关闭并且无法打开对话窗口。错误信息正是:
test.cpp:10:19:警告:不推荐将字符串常量转换为 'LPWSTR {aka wchar_t*}' [-Wwrite-strings]
#include <windows.h>
int main() {
OPENFILENAMEW ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFile = L"file name";
}