我试了一下包含mfc类库的方法,参考
标题 在SDK程序中使用MFC中的辅助类 yangcl [收藏]
关键字 MFC中的辅助类
1.加入相应的头文件由于在SDK程序中一定要包含windows.h头文件,所以在使用MFC中的类时,
如加入afx.h一类的头文件会有一个提示与windows.h相冲突,解决的办法是,
去掉windows.h,然后在所有的.h文件前加入#include "stdafx.h"
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls#include <afxcmn.h>2。 更改编译设置
不过在用到cfiledialog时,
CFileDialog tm_fileDlg( true, "avi", NULL, OFN_ALLOWMULTISELECT|OFN_OVERWRITEPROMPT,
"avi文件(*.avi)|*.avi|", this); if(tm_fileDlg.DoModal() == IDCANCEL)
return;总是在这儿出错, 调试就进入汇编代码了。郁闷
标题 在SDK程序中使用MFC中的辅助类 yangcl [收藏]
关键字 MFC中的辅助类
1.加入相应的头文件由于在SDK程序中一定要包含windows.h头文件,所以在使用MFC中的类时,
如加入afx.h一类的头文件会有一个提示与windows.h相冲突,解决的办法是,
去掉windows.h,然后在所有的.h文件前加入#include "stdafx.h"
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls#include <afxcmn.h>2。 更改编译设置
不过在用到cfiledialog时,
CFileDialog tm_fileDlg( true, "avi", NULL, OFN_ALLOWMULTISELECT|OFN_OVERWRITEPROMPT,
"avi文件(*.avi)|*.avi|", this); if(tm_fileDlg.DoModal() == IDCANCEL)
return;总是在这儿出错, 调试就进入汇编代码了。郁闷
填充一个结构体就可以得到和CFileDialog完全一样的效果了,其实CFileDialog就是包装的这两个函数哈。
OPENFILENAME结构体,关于结构的成员请参阅MSDN打开和保存文存请根据自己的文件格式自己处理
一般就是
用CreateFile先关联文件获文件句柄,有了文件句柄,我们想做什么都行了
具体函数MSDN