1个回答
展开全部
C++的WinSDK\MFC可以实现: MFC方法(要在工程属性里设置MFC支持,最好只在MFC工程里使用): #include "afxdlgs.h" CFileDialog fileDlg( 0 /*改为1则为打开对话框*/, 0, 0, 0, "自设文件类型(*.abc)|*.abc|所有文件(*.*)|*.*||", 0); if (fileDlg.DoModal()==1) { AfxMessageBox(fileDlg.GetPathName()); } WinSDK方法: #include "windows.h" char lpFilePath[255]={'\0'}; OPENFILENAME ofn ; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof (OPENFILENAME) ; ofn.hwndOwner = hwnd ; ofn.hInstance = NULL ; ofn.lpstrFilter = "自设文件类型(*.abc)\0*.abc\0所有文件(*.*)\0*.*\0\0", ; ofn.lpstrCustomFilter = NULL ; ofn.nMaxCustFilter = 0 ; ofn.nFilterIndex = 0 ; ofn.lpstrFile = lpFilePath ; // 设置存放文件路径缓冲区 ofn.nMaxFile = MAX_PATH ; //缓冲区大小; ofn.lpstrFileTitle = NULL ; // 设置存放文件名称缓冲区 ofn.nMaxFileTitle = MAX_PATH ; //缓冲区大小; ofn.lpstrInitialDir = NULL ; ofn.lpstrTitle = "另寸为" ; ofn.Flags = 0; ofn.nFileOffset = 0 ; ofn.nFileExtension = 0 ; ofn.lpstrDefExt = 0 ; //ofn.lCustData = 0L ; ofn.lpfnHook = NULL ; ofn.lpTemplateName = NULL ; GetOpenFileName (&ofn) ;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询