Saturday, October 26, 2013

Basic MFC Console Program

This is a basic MFC console program.

// TestMFCConsole.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include "TestMFCConsole.h"
 
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
 
 
// The one and only application object
 
CWinApp theApp;
 
using namespace std;
 
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
    int nRetCode = 0;
 
    HMODULE hModule = ::GetModuleHandle(NULL);
 
    if (hModule != NULL)
    {
        // initialize MFC and print and error on failure
        if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0))
        {
            // TODO: change error code to suit your needs
            _tprintf(_T("Fatal Error: MFC initialization failed\n"));
            nRetCode = 1;
        }
        else
        {
            _tprintf(_T("This application is based on MFC\n"));
        }
    }
    else
    {
        // TODO: change error code to suit your needs
        _tprintf(_T("Fatal Error: GetModuleHandle failed\n"));
        nRetCode = 1;
    }
 
    return nRetCode;
}



No comments:

Post a Comment