Hello, Win32 API(VB6) World!
Posted on 4月 18th, 2012 by cx20
Win32 API(VB6)
Win32 API は、Windows の機能にアクセスする為の API(Application Programming Interface)である。
以下は VB6 からの呼出し例である。
ソースコード
Declare Function MessageBox Lib "User32.dll" Alias "MessageBoxA" ( _ ByVal hWnd As Long, _ ByVal lpText As String, _ ByVal lpCaption As String, _ ByVal uType As Long _ ) As Integer Sub Main() MessageBox 0, "Hello, Win32 API(VB6) World!", "Hello, World!", vbOKOnly End Sub |
Win32 データ型と VB6 データ型の対応は主に以下のようになっている。
| Win32 データ型 | C/C++ データ型 | VB6 |
|---|---|---|
| HANDLE | void * | Long |
| BYTE | unsigned char | Byte |
| SHORT | short | Integer |
| WORD | unsigned short | Integer |
| INT | int | Long |
| UINT | unsigned int | Long |
| LONG | long | Long |
| BOOL | int | Long |
| DWORD | unsigned long | Long |
| ULONG | unsigned long | Long |
| CHAR | char | Byte |
| WCHAR | wchar_t | Integer |
| LPSTR | char * | String |
| LPCSTR | const char * | String |
| LPWSTR | wchar_t * | Long (StrPtr) |
| LPCWSTR | const wchar_t * | Long (StrPtr) |
| FLOAT | float | Single |
| DOUBLE | double | Double |
コンパイル方法
C:¥> vb6 /make hello.vbp |
実行結果
--------------------------- Hello, World! --------------------------- Hello, Win32 API(VB6) World! --------------------------- OK --------------------------- |
Tags: Win32 API