C++파일 선택 대화 상자 함수 GetOpenFileName 에서 사용 할 demo

#include <windows.h>
#include <commdlg.h>

int main()  
{  
	//     
	OPENFILENAME ofn;      //        。   
	TCHAR szFile[MAX_PATH]; //             。             
	//           。   
	ZeroMemory(&ofn, sizeof(OPENFILENAME));  
	ofn.lStructSize = sizeof(OPENFILENAME);  
	ofn.hwndOwner = NULL;  
	ofn.lpstrFile = szFile;  
	ofn.lpstrFile[0] = '\0'; 
	ofn.nMaxFile = sizeof(szFile);  
	ofn.lpstrFilter = "All(*.*)\0*.*\0Text(*.txt)\0*.TXT\0\0";  
	ofn.nFilterIndex = 1;  
	ofn.lpstrFileTitle = NULL;  
	ofn.nMaxFileTitle = 0;  
	ofn.lpstrInitialDir = NULL;  
	ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;  
	//ofn.lpTemplateName =  MAKEINTRESOURCE(ID_TEMP_DIALOG);  
	//            。   

	if ( GetOpenFileName(&ofn) )  
	{  
		//       。   
		OutputDebugString(szFile);  
		OutputDebugString("\r
"); } system("pause"); return 0; }

좋은 웹페이지 즐겨찾기