Archive for 4月 14th, 2012

  1. Hello, Win32 API(C++) World!

    Posted on 4月 14th, 2012 by cx20

    Win32 API(C++)

    Win32 API は、Windows の機能にアクセスする為の API(Application Programming Interface)である。
    以下は C++ からの呼出し例である。

    ソースコード

    #include <windows.h>
    #include <tchar.h>
     
    int _tmain( int argc, TCHAR* argv[] )
    {
        MessageBox( NULL, _T("Hello, Win32 API(C++) World!"), _T("Hello, World!"), MB_OK );
        return 0;
    }

    コンパイル方法(Visual C++)

    C:¥> cl hello.cpp /link user32.lib

    実行結果

    ---------------------------
    Hello, World!
    ---------------------------
    Hello, Win32 API(C++) World!
    ---------------------------
    OK   
    ---------------------------