The WIN32API stuff in this site may be hazardous to your system's health. You should use them properly, otherwise you may crash your application, Visual Basic and even your system. While every attempt was to made sure that information and download included in this site are correct, use them at your own risk.
Win32 API Character Sets
Win32 API supports three different character sets :
1] ANSI, Often referred as ASCII - Each character occupies one byte.
2] Double byte character set (DBCS)
3] Unicode character set, all chars are two bytes wide
The DBCS and unicode character sets are important, many international languages include hundreds of characters. To defferntiate between the ANSI and unicode character sets, Microsoft has created two sets of routines. Both versions have the common API name (e.g. netrpx). The unicode version of the routines appends a W to the end of the name (e.g. netrpxW) and the API versions appends A (as in netrpxA).
Win32 API Data Types
Since window is written in C, all the Win32API calls use C data types, VB data types are compatible with C data types
Calling a Win32 API Routine
To call a Win32 API routine from VB code, you need to create the reference to that routine. VB 6.0 come with API text viewer, you can use it to copy and paste rountines into your VB code.
Declaring a Win32 API Call
Follwing is the Win32 API Routine for shuttingh down windows.
Public Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Where ~~~
ExitWindowEx is the name of the routine. Lib is the name of the library that contains the routines. Alias contains the real name of the routine. ByVal uFlags As Long, ByVal dwReserved As Long are the arguments. Long is the data type of the value returned by the function. ByVal means that argument is passed by value.
Win32 API Structures and Constants
Many Win32API return data in C structure. Its quivalent to a Visual Basic Type statement.
Constant Examples
Public Const EWX_FORCE = 4
Public Const EWX_LOGOFF = 0
Public Const EWX_REBOOT = 2
Public Const EWX_SHUTDOWN = 1
Type Examples
Public Type midi
songptrpos As Long
End Type
Now you are all set for Win32 API, have fun.