How To Call Windows CE APIs from VBCE or eVB (209014)



The information in this article applies to:

  • Microsoft Windows CE Toolkit for Visual Basic 6.0
  • Microsoft eMbedded Visual Basic 3.0

This article was previously published under Q209014

SUMMARY

This article provides a generic overview of how to call APIs from Windows CE Toolkit for Visual Basic 6.0 (VBCE 6.0) or eMbedded Visual Basic 3.0 (eVB) applications and issues that may arise.

MORE INFORMATION

VBCE 6.0 and eVB 3.0 introduce the Declare statement and the ability to call Windows CE API functions and sub procedures. The Declare statement has the general form:

Function <name> Lib "coredll.dll" [Alias aliasname] ([parameters]) As <type>

Example:
Declare Function MessageBeep Lib "Coredll" (ByVal wType As Long) As Long
				
Detailed information about the Windows CE and eVB API functions and sub procedures is contained in the Online Help for the specific platform and for VBCE or eVB. It is also contained in the Micrososft Developer Network (MSDN).

The toolkit also includes an important text file (WinCEAPI.txt) with sample procedure declarations and constant definitions. In most cases, the declarations and constant definitions can be copied directly from the text file and pasted into VBCE or eVB code. However, some of the information within the WinCEAPI.txt file is not supported in VBCE 6.0 or eVB 3.0:
  • Structures as data types are not supported.

  • Constants cannot be defined using other constants or using bitwise operators to combine definitions. Use the value of the other constant or resulting bitwise operation when defining the constants.

    For example, the following is not allowed:
    Const LHND = (LMEM_MOVEABLE + LMEM_ZEROINIT)
    						
    Instead, use this code:
    Const LHND = &H42
    						
  • Use of the Any data type. Instead, declare "As Any" parameters "As Variant," for example:
    Declare Function ClipCursor Lib "Coredll" (lpRect As Variant) As Long
    						
    This applies to the following subs/functions: AppendMenu(), ClipCursor(), CreateBitmap(), CreateCursor(), CreateDIBPatternBrushPt(), CreateProcess(), CreateThread(), CreateWindowEx(),DeviceIoControl(), FlushInstructionCache(), FlushViewOfFile(), FormatMessage(), GetObject(), HeapFree(), HeapReAlloc(), HeapSize(), HeapValidate(), InsertMenu(), IsBadReadPtr(), IsBadWritePtr(), MapWindowPoints(), ReadFile(), ReadProcessMemory(), RegQueryValueEx(), RegSetValueEx(), SendMessage(), SetDeviceGammaRamp(), SetDIBits(), StretchDIBits(), SystemParametersInfo(), TlsSetValue(), UnmapViewOfFile(), VirtualAlloc(), VirtualFree(), VirtualProtect(), WnetEnumResource(), WnetGetUniversalName(), WnetOpenEnum(), WriteFile(), WriteProcessMemory().

  • References to the "user32" library should instead refer to the "coredll" library.

    This applies to the following subs/functions: BeginDeferWindowPos(), CopyImage(), CreateDesktop(), CreateDialogIndirectParam(), CreateDialogParam(), GetKeyboardLayout(), GetKeyboardLayoutList(), GetMenuContextHelpId(), GetMenuDefaultItem(), UnpackDDElParam().

REFERENCES

WinCEAPI.txt file
Online Help for Windows CE Toolkit for Visual Basic
Platform SDK Online Help Topics

Modification Type:MinorLast Reviewed:8/19/2005
Keywords:kbAPI kbhowto kbToolkit KB209014