wstring wstrSaveFileName = L"C:\\1.txt";
OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.lpstrFile = (LPWSTR)wstrSaveFileName.c_str();
wstring strExFilter;
wstring strExt = PathFindExtension(wstrSaveFileName.c_str());//得到后缀名
if (strExt == L".txt" || strExt == L".TXT")
strExFilter = L"文本(*.txt)\0\0";
else if (strExt == L".png" || strExt == L".PNG")
strExFilter = L"图片(*.png)\0\0";
else if (strExt == L".jpg" || strExt == L".JPG")
strExFilter = L"图片(*.jpg)\0\0";
else if (strExt == L".bmp" || strExt == L".BMP")
strExFilter = L"图片(*.bmp)\0\0";
else
strExFilter = L"其他(*.*) \0\0";
ofn.lpstrFilter = strExFilter.c_str();
ofn.nMaxFile = MAX_PATH;
ofn.hwndOwner = GetHWND();
ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_EXTENSIONDIFFERENT;
if (GetSaveFileName(&ofn))
{
wstring szGetFilePath = ofn.lpstrFile;
int i = 0;
i++;
}