Popular Windows API Functions to Use with Visual Basic 4.0

ID: Q146650


The information in this article applies to:
  • Microsoft Visual Basic Standard, Professional, and Enterprise Editions, 16-bit and 32-bit, for Windows, version 4.0


SUMMARY

Below is a summary of API (application programming interface) functions for Microsoft Windows that programmers commonly use to extend the abilities of Microsoft Visual Basic for Windows. These functions can be called from either Win16 or Win32 and should behave similarly in both environments unless specifically noted.


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 write the information stored in the initialization file for Windows (WIN.INI). NOTE: Initialization file functions remain in Win32 for backward compatibility with Win16. However, Win32 applications, should use the registry for initialization.


  • GetPrivateProfileString, GetPrivateProfileInt, WritePrivateProfileString: Get or set the information in a given initialization file (ininame.INI).
    NOTE: Initialization file functions remain in Win32 for backward compatibility with Win16. However, Win32 applications, should use the registry for initialization.


  • 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(16-bit) or GlobalMemoryStatus(32-bit), GetVersion, GetWinFlags(16-bit) or GetSystemInfo(32-bit): Check system settings for Microsoft Windows, such as for reporting in an About box under a Help menu.


  • GetModuleFileName, GetModuleHandle, GetModuleUsage(16-bit only): Get full pathname of the executable file from which the specified module was loaded. NOTE: Each Win32-based application runs in its own address space. Therefore GetModuleUsage does not apply.


  • 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.


  • 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 are compressed by the COMPRESS.EXE utility supplied with the Windows Software Development Kit (SDK) versions 3.0 and 3.1.


  • OpenComm(16-bit), WriteComm(16-bit), GetCommEventMask(16-bit), SetCommState: Use the COMn: serial communications port. NOTE: OpenComm, WriteComm, and GetCommEventMask is no longer found in the Win32 API set.


  • RoundRect, FillRect, ExtFloodFill, StretchBlt: Perform graphic operations beyond Visual Basic capabilities.


  • SetSysModalWindow (16-bit only): Set a window to be system-modal, such as for a screen saver's password dialog box. NOTE: The new input model does not allow for System Modal windows.


  • SndPlaySound: Play waveform .WAV sound file sounds.


  • WinExec: Run a Windows-based or other application, as an alternative to Visual 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.



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.


  • "Microsoft Win32 Programmer's Reference Volumes 1 - 5" published by Microsoft Press.


Additional query words: 4.00 vb4win vb4all

Keywords : kbref kbDocs PrgOther
Version : WINDOWS:4.0
Platform : WINDOWS
Issue type :


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