WIN32通用控件之打开对话框获取文件路径

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

 

posted @ 2014-11-17 23:31  疯陈演义  阅读(400)  评论(0编辑  收藏  举报