HOWTO: Call Windows CE APIs from VBCE

ID: Q209014


The information in this article applies to:
  • Microsoft Windows CE Toolkit for Visual Basic 6.0, version 1.0


SUMMARY

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


MORE INFORMATION

VBCE 6.0 introduces 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 API functions and sub procedures is contained in the Online Help for the specific platform and for VBCE. 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 code. However, some of the information within the WinCEAPI.txt file is not supported in VBCE 6:
  • 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

Additional query words:

Keywords : kbAPI kbToolkit kbVBp600 kbWinCE kbGrpVB
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: November 24, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.