OPENFILENAME ofn; char FileName[MAX_PATH]; memset(&ofn,0,sizeof(OPENFILENAME)); memset(FileName,0,sizeof(char)*MAX_PATH); ofn.lStructSize=sizeof(OPENFILENAME); ofn.lpstrFilter="文本文档 *.TXT"; ofn.lpstrFile=FileName; ofn.nMaxFile=MAX_PATH; ofn.Flags=OFN_FILEMUSTEXIST; if(GetOpenFileName(&ofn))//FileName得到用户所选择文件的路径 { MessageBox(NULL,FileName,NULL,NULL); }