VB 3.0 Popular Windows API Functions Used from VB 3.0
ID: Q109290
|
The information in this article applies to:
-
Microsoft Visual Basic Standard and Professional Editions for Windows, version 3.0
SUMMARY
Below is a summary of Application Programmer's Interface (API) functions
for Microsoft Windows that programmers commonly use to extend the
abilities of Visual Basic.
MORE INFORMATION
Commonly-Used API Functions for Windows
The following Windows API functions are very useful for Visual Basic
programmers:
- BitBlt: Move a bitmap from a source device context to a destination.
- ExtractIcon, DrawIcon, and LoadIcon: Manipulate icons.
- FindExecutable: Find and retrieve the executable filename that is
associated with a specified filename.
- GetWindowsDirectory: Get the pathname of the Windows directory.
- GetSystemDirectory: Get the pathname of the Windows system subdirectory.
- GetSystemMetrics: Get widths and heights of the display elements of
Microsoft Windows.
- GetTempFileName: Return a temporary filename and path using the TEMP
environment variable.
- GetWindowPlacement and SetWindowPlacement: Get or set the show state and
the normal (restored), minimized, and maximized positions of a window.
- GetProfileString, GetProfileInt, WriteProfileString: Get or set the
information stored in the initialization file for Windows (WIN.INI).
- GetPrivateProfileString, GetPrivateProfileInt, SetPrivateProfileString:
Get or set the information in a given initialization file (ininame.INI).
- SendMessage: Send Windows messages to control applications. For example,
the LB_SETTABSTOPS message sets tab stops in a list box. LB_FINDSTRING
finds the first string in the list box which matches prefix text.
Hundreds of other messages are available.
- SetCapture: Send all mouse input to the specified window, regardless of
the cursor position.
- SetWindowPos: Change the size, position, and ordering of child, pop-up,
and top-level windows.
- SetCursorPos: Reposition the mouse pointer (cursor).
Additional Commonly-Used API Functions for Windows
The following API functions for Windows are also very useful for Visual
Basic programmers:
- BringWindowToTop, SetActiveWindow: Activate a window.
- CreateCompatibleDC: Prepare image in memory, such as before copying an
image to the compatible device.
- DeleteObject, ReleaseDC: Remove object or device context from memory.
- DragAcceptFiles, DragFinish: Support File Manager drag/drop file
ability.
- FindWindow, ShowWindow: Check to see if given applications are currently
running. This is useful before you perform Dynamic Data Exchange (DDE).
- GetActiveWindow, IsWindow: Find out when a Shell function has finished
loading a program.
- GetDesktopWindow: Get a handle to the Windows desktop window, which
covers the entire screen and is the area on top of which all icons and
other windows are painted.
- GetFreeSpace, GetVersion, GetWinFlags: Check system settings for
Microsoft Windows, such as for reporting in an About box under a Help
menu.
- GetModuleFileName, GetModuleHandle, GetModuleUsage: Get full pathname of
the executable file from which the specified module was loaded.
- GetPaletteEntries, CreatePen, SelectObject: Manipulate color palettes.
- GetParent: Get handle of specified window's parent.
- EnumChildWindows: Get list of child windows that belong to specified
parent window.
- GetWindowLong, SetWindowLong: Get or set window style information.
- GetWindowText: Get the caption title of a window or the text in a
control.
- IsAppLoaded, IsIconic, IsWindowVisible: Find the state of the windows of
an application -- visible, loaded, or minimized to an icon.
- LoadCursor, DestroyCursor, GetCursorPos: Handle different mouse cursors.
- LZOpenFile, LZCopy, LZClose: Manipulate compressed files. See the
LZEXPAND.DLL file that ships with Visual Basic version 3.0. The
functions in LZEXPAND.DLL manipulate files that compressed by the
COMPRESS.EXE utility supplied with the Windows Software Development Kit
(SDK) versions 3.0 and 3.1.
- OpenComm, WriteComm, GetCommEventMask, SetCommState: Use the COMn:
serial communications port.
- RoundRect, FillRect, ExtFloodFill, StretchBlt: Perform graphic
operations beyond Visual Basic capabilities.
- SetSysModalWindow: Set a window to be system-modal, such as for a
screen saver's password dialog box.
- SndPlaySound: Play waveform .WAV sound file sounds.
- WinExec: Run a Windows-based or other application, as an
alternative to Basic's Shell function.
- WinHelp: Invoke WINHELP.EXE, the Windows Help application. Useful as
an alternative to invoking WINHELP.EXE by setting the Common Dialog's
Action property to a value of 6.
Visual Basic Setup Kit API Routines
- DiskSpaceFree: Get free space on specified disk. The Declare statement
is found in SETUP1.GLB in the SETUPKIT subdirectory for Visual Basic:
Declare Function DiskSpaceFree Lib "SETUPKIT.DLL" () As Long
- GetFileVersionInfoSize and GetFileVersionInfo in Windows API: Get file
version information from the version-information resource that was
added to an application using the VERSIONINFO statement.
The VERSIONINFO statement is found in the file installation library
found in Windows version 3.1. The resource contains such information
about the file as its version number, its intended operating system,
and its original filename. The resource is intended to be used with
the Windows file installation library functions.
The GetFileVersion function is defined in SETUP1.BAS in the SETUPKIT
subdirectory for Visual Basic. The GetFileVersion function invokes the
GetFileVersionInfo and GetFileVersionInfoSize Windows API functions.
The following Declare statements are taken from SETUP1.GLB:
Declare Function GetFileVersionInfoSize Lib "VER.DLL"
(ByVal lpszFileName As String, lpdwHandle As Long) As Long
Declare Function GetFileVersionInfo Lib "VER.DLL"
(ByVal lpszFileName As String, ByVal lpdwHandle As Long,
ByVal cbbuf As Long, ByVal lpvdata As String) As Integer
REFERENCES
- "Microsoft Windows Programmer's Reference," published by Microsoft Press.
- "Visual Basic - Game Programming with Windows," by Craig, published by
Microsoft Press.
- "PC Magazine's Visual Basic Programmer's Guide to the Windows API" by
Daniel Appleman (of Desaware), published by Ziff-Davis Press. This
reference describes most Windows API functions that can be used from
within Visual Basic.
Additional query words:
3.00
Keywords :
Version : WINDOWS:3.0
Platform : WINDOWS
Issue type :
Last Reviewed: May 13, 1999