1.打开VC2017
问题:VS2017无法打开sdkddkver.h
vs installer 右侧的标准库模块勾上
2.test.h
#pragma once //为了防止头文件被重复引用
#include <sdkddkver.h>//定义开发包SDK的版本
#include <afxwin.h> //MFC部分类库在这个文件里,所以必须包含
#include <afxwinappex.h> //应用程序类CWinAPPEx在这里面定义
#include <afxframewndex.h> //窗口框架类CFrameWndEx在这里面定义
class CTestApp : public CWinAppEx //定义应用层
{
public:
virtual BOOL InitInstance();//重载虚函数
};
test.cpp
#include "test.h"
CTestApp theApp;//定义引用类全局对象
BOOL CTestApp::InitInstance() //应用类的初始化函数
{
CWinAppEx::InitInstance();
//声明本程序的设置存储在注册表中,而不是INI文件
SetRegistryKey(TEXT("Hello MFC app."));
AfxMessageBox(_T("Hello World,来自MFC"));//显示消息框
return TRUE;
}
3.运行