我只想知道用户选择了哪个过滤器。
void LoadFilePath(char *_szFilePath, int _nFilePathSize)
{
if( !_szFilePath) return;
if( _nFilePathSize < MAX_PATH ) return;
OPENFILENAME ofn;
char lpstrFile[MAX_PATH] = "";
memset(&ofn, 0 ,sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = NULL;
ofn.lpstrFilter = "VTX File(*.vtx)\0*.vtx\0";
ofn.lpstrFile = lpstrFile;
ofn.lpstrInitialDir = ".\\";
ofn.Flags = OFN_NOCHANGEDIR;
ofn.nMaxFile = MAX_PATH;
if(GetOpenFileName(&ofn) != 0 ){
sprintf(_szFilePath,"%s",ofn.lpstrFile);
}
if(ofn.lpstrFile[0] == 0 )
{
printf("no selected file \n");
system("pause()");
exit(0);
}
}
打开文件资源管理器并将路径保存到第二个参数是简单的代码。过滤器是 .vtx 但我尝试添加更多。然后我想选择哪个过滤器用户。有什么好办法吗?谢谢你