Wiki Home

Win 32 API

Namespace: Wiki
API a set of functions accessible from the Win32 platform, generally referring to the Platform SDKOffsite link to as well. It's all those little things that Windows does to you that you'd really like to get at, but aren't documented inside the VFP Help manuals.
Some things you may want to do with the Win 32 API: (Add new requests at the bottom of the topic)
Issue a "NET SEND" command from within VFP Net Send
Move third party windows into VFP, or change "Top Level" status of any VFP Form (or embed one VFP MDI window inside another for any reason, including a form with a partially scrolling section) Take Window / Free Window
Rename a Directory (folder) Win32Api_MoveFile
Determine the machine's IP address WinCom_WinSock
Add an icon to the systray Win32Api_Shell_NotifyIcon
Create Callback functions in VFP Callbacks And Events
How to create Structures to use with API functions Api Structures
Exit / Logoff / Restart Windows Win32Api_ExitWindowsEx
Reference showing how to use many API function in VFP
Decoding the drive mapping (convert a mapped drive and path to its UNC equivalent)
Obtain Date and Time Information from a Server
Q249716 Offsite link to;EN-US;Q249716
Get (or Set) the User-Selected Windows System Colors
GetSysColorOffsite link to
/ Set Sys Colors
Get the current user's name
Get User NameOffsite link to
Place part of main VFP window on the clipboard as BMP
Create a non-rectangular form
Round Dialog Form
Get Windows Locale currency format Get Currency Format
Get the nearest color in the current Windows Palette. For preventing ugly interlacing.
Get Closest Color

If you want to use it, there are some useful references. The most useful is the MSDN Library, at present a three CD set updated quarterly (also available on DVD) which contains all the documentation for the WIndows Platforms and development languages. It's not free. Much of the content is available online at the MSDN_Online Site. Do yourself a favor. Spend the money and get it on CD with quarterly updates. With all the changes to the Windows platform, it'll pay for itself very quickly, since it includes stuff you'd otherwise have to buy platform resource kits to find out.

If you're not allergic to C, The Windows NT Win32 API Super Bible - ISBN 1571690891 - is my favorite reference; it's published by the Waite Group. It's well-written and thorough in what it covers, and it tells you to buy the damned MSDN Library, too. It presents the basics of the API in a very logical fashion, and between Christof Lange's STRUCT class and my CLSHEAP stuff, there isn't much you can't translate to work with VFP unless it needs callbacks, or uses a calling syntax other than the standard C-style calling syntax. Then you need to write a wrapper on the API call to make it accessible, probably in C...

The C-phobic are likely to find Visual Basic Programmer's Guide to the Win32 API - ISBN 0672315904 - more approachable; Dan Appleman wrote a really terrific book, even if it is in the awful, evil language whose name must not be spoken. I hate VB with a passion. This is the one VB book you must buy. It's published by SAMS, is very readable and VB is closer to native VFP than C is. While the author doesn't tell you to buy an MSDN subscription, he does point to a couple of other books he's written on the Win32 API and VB, which do point to the MSDN Library.

The website is a good reference source for API functions.

There is a cool utility program called API-Guide by the KPD-Team at
-- John Durbin

A breakdown of the Win 32 Api can be found in the win32api.txt file. It gives structures for each procedure/function. Win 32 Api.csv gives a description of each procedure with the element, platform, component, header, and import library names. These files can be found in the Visual Studio subdirectories. Both are very useful when coding for those little interruptions the Windows platform surprises you with.

Another good function suite for ftp is the WinInet32.dll file.
-- ChrisJohnson
Pause execution of a program for a specified interval. Better than using WAIT or INKEY()
DECLARE Sleep IN Win32API INTEGER nMilliseconds

* Pause for 5 seconds
nSleepSeconds = 5
nMilliseconds = nSleepSeconds * 1000

What do YOU want to do with the Win 32 API?

I am looking for some help on how to use the Net User Get GroupsOffsite link to
function in net32api.

Its declare is :
NET_API_STATUS Net User Get GroupsOffsite link to
LPCWSTR servername,
LPCWSTR username,
DWORD level,
LPBYTE *bufptr,
DWORD prefmaxlen,
LPDWORD entriesread,
LPDWORD totalentries

But I have no idea how to do UNICODE or arrays of structs in VFP. If someone could help me find a way to wrap this api call in VFP, it would really help a big project.

You can create the structure using the method in Api Structure Class ... To create an array of structures (or to read an array of structures, use SubStr( lcArr, lnStrSize*lnIdx, lnStrSize) to pull out the individual structure)

As for the UNICODE, VFP7+ has a parameter for Str Conv to convert to and from Uni Code, and in VFP6, you can convert Uni Code to Double Byte, then From Double Byte to Single Byte, or the other way around. - wgcs
How do I get/set printer setup info with more control than getprinter() or sys(1037)? -- ?cfk

[2001.04.24] Carl:
loComDialog = newobject( "mscomdlg.commondialog" )

what you are looking for? -- ?df
How about a practical example ?! -- ?edyshor
? "Printer ", SET("Printer",2)
loComDialog = newobject( "mscomdlg.commondialog" )
? "Printer ", SET("Printer",2)

This doesn't work with VFP9SP2 under XPPro SP3. If i'm not using it corectly a practical example will be truly appreciated. -- ?edyshor

The Windows Application Programming Interface (API) (also known as the Win 32 API) is a set of base services built into the operating system and available from various system DLLs. The API allows developers to leverage system-level code and to emulate the look and feel of the OS by using the OS's own system calls.

Examples of using the Win 32 API are displaying the windows dialog to browse to a folder, launching a program using Shell Execute or decoding the drive mapping (converting a mapped drive to its UNC equivalent). For an example of this last use, see

Access to the Win 32 API from VFP is via the DECLARE - DLL command
How to check the password for the current logged user from an application using API calls? PM
See also: Api Structures, Api Viewer
Contributors: Andrew Coates Anatoliy Mogylevets Alex Feldstein
Category Windows API Category Code Samples Category Questions
( Topic last updated: 2009.03.18 01:37:20 PM )