Archive for 5月 1st, 2012

  1. Hello, Win32 API(UWSC) World!

    Posted on 5月 1st, 2012 by cx20

    Win32 API(UWSC)

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

    ソースコード

    Option Explicit
     
    DEF_DLL MessageBoxA( hwnd, string, string, long ): long: user32.dll
     
    Main()
     
    Procedure Main()
        MessageBoxA( 0, "Hello, Win32 API(UWSC) World!", "Hello, World!", 0 )
    Fend

    Win32 データ型と UWSC データ型(DEF_DLL 構文)の対応は主に以下のようになっている。

    Win32 データ型 C/C++ データ型 UWSC データ型
    INT int int
    LONG long long
    BOOL int bool
    UINT unsigned int uint
    HWND void * hwnd
    LPCSTR const char * string
    LPCWSTR const wchar_t * Wstring
    FLOAT float float
    DOUBLE double double
    WORD unsigned short word
    DWORD unsigned long dword
    BYTE unsigned char byte
    CHAR char char
    PCHAR char * pchar
    WCHAR wchar_t Wchar
    PWCHAR wchar_t * pWchar
    BOOLEAN unsigned char boolean
    LONGLONG __int64 longlong

    実行方法

    C:¥> uwsc hello.uws

    実行結果

    ---------------------------
    Hello, World!
    ---------------------------
    Hello, Win32 API(UWSC) World!
    ---------------------------
    OK   
    ---------------------------