ホーム » .NET » CLI + MFC

2013年7月
 123456
78910111213
14151617181920
21222324252627
28293031  

カテゴリー

アーカイブ

ブログ統計情報

  • 79,628 アクセス



CLI + MFC

CLR コンソール アプリケーションを作成.
Console::WriteLine を追加.


#include “stdafx.h”
using namespace System;
int main(array ^args)
{
  Console::WriteLine(L”Hello World”);
#ifdef _WIN32
  Console::WriteLine(L”WIN32″);
#endif
#ifdef __cplusplus_cli
  Console::WriteLine(L”CLI”);
#endif
#ifdef __CLR_VER
  Console::WriteLine(__CLR_VER);
#endif
#ifdef _MFC_VER
  Console::WriteLine(_MFC_VER);
#endif
  return 0;
  }
実行すると,
C:\…>”C:\…\debug\ConAp.exe”
Hello World
WIN32
CLI
20050727


これに MFC の機能を追加しようとしたがわからなかったので.MFC コンソール AP を作成して /clr を追加することにした.


#include “stdafx.h”
#include “ConMFC.h”
//
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
//
using namespace System;
// 唯一のアプリケーション オブジェクトです。
CWinApp theApp;
//
using namespace std;
//
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
  int nRetCode = 0;
//
  if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))  {
    _tprintf(_T(“致命的なエラー: MFC の初期化ができませんでした。\n”));
    nRetCode = 1;
  }
  else {
    // TODO: アプリケーションの動作を記述するコードをここに挿入してください。
  }
  Console::WriteLine(L”Hello World”);
#ifdef _WIN32
  Console::WriteLine(L”WIN32″);
#endif
#ifdef __cplusplus_cli
  Console::WriteLine(L”CLI”);
#endif
#ifdef __CLR_VER
  Console::WriteLine(__CLR_VER);
#endif
#ifdef _MFC_VER
  Console::WriteLine(_MFC_VER);
#endif
  return nRetCode;
}
実行すると,
C:\…>”C:\…\debug\ConMFC.exe”
Hello World
WIN32
CLI
20050727
2048


CLR のバージョンは,2.0.50727
MFC は 0x0800
VC 定義済みマクロ

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

コメントする

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

%d人のブロガーが「いいね」をつけました。