WebSite  
 
Home Page > IT School

Win32 API In Visual Basic

03-02-2008
Article by:
Pradeep Mamgain

Do you like this Article?
Excellent
Good
Poor
Dad
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.




 User Comments                                                                                



 Other Articles

Your name:
Your email:
Subject:
Comment Text:



 Photo Gallery
 
Latest IT News
Google scores 61% of the search market Google scores 61% of...

The guys at the ‘plex must be rubbing their hands with glee over the figures from ComScore’s ‘first comprehensive study...

Would your Firefox need mouse gestures? Would your Firefox need...

I remember when I first tried Opera, that was supposed to be “the fastest browser on Earth”, I accidentally...

The Top 12 Signs That Your Computer Has Spyware The Top 12 Signs That...

How to tell if your computer has spyware on it. Sign Number...

How to create Screensaver from Flash movie? How to create...

Have you ever thought your Flash movie would make a great...

7 very Important Ways To Prevent Spam 7 very Important Ways...

Spam is the bane of everyone’s existence. Unsolicited mail...

Keeping Your Home PC Virus-Free Keeping Your Home PC...

There are thousands of them and more appear every day. They...

 
 
Africaninet.com  Copyright © 2006 Africaninet.com  |Terms of Use for Africaninet template and Privacy Policy and Safety Information/ All rights reserved.
Powered by: PHPCow.com