winapi

Is user a member of the Administrators group

Sometimes it's important to know if application is running under account that is a member of the Administrators group. There're a few ways to accomplish that.

Obtaining DLL-specific version information

Most Windows Shell and common controls DLLs implement DllGetVersion function. It allows applications to obtain DLL-specific version information to make sure that required functionality in a DLL is implemented.
The Windows API support class is used to handle Windows API structures.

Generate GUID

UDF below generates 128-bit GUID and returns it as a string in the format 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.

MSDN:

Creating directory preserving name case

MSDN:

File operations with Progressbar

It's based on the late Ed Rauh's code around SHFileOperation Win API and requires his Heap allocation class. It supports wild cards and shows standard Windows progress bar.

This is sample code. Add error handling and adjust to your requirements as necessary.

* Copy file to different name
llSuccess = FileOpWithProgressbar("H:\TEMP\tord.dbf", "H:\TMP\TEST.dbf", "Copy")
* Copy with the same name
llSuccess = FileOpWithProgressbar("H:\TEMP\tord.dbf", "H:\TMP\", "Copy")
* Copy all dbf's

Windows limitations on file and path name

The limitations have been pulled from Windows SDK header file

Windows API support class

The class below simplifies use of Windows API function by providing methods to convert data between VFP types and Windows API types/structures

Most of the code was borrowed from Heap allocation class (clsheap) by late Ed Rauh.

This is sample code. Add error handling and adjust to your requirements as necessary.

DEFINE CLASS WinApiSupport AS Custom
 
	* Converts VFP number to the Long integer
	FUNCTION Num2Long(tnNum)
		LOCAL lcStringl
		lcString = SPACE(4)

Using Sparse Files sample

Sparse files are only supported under Windows 2000 and later and the file must be on a volume that is NTFS 5.0 or later.

Setting the Backup and Restore Privileges

The backup and restore privileges are required of all backup and restore applications. These privileges can be programmatically set, and the following example can be used to set these privileges. Based on Setting the Backup and Restore Privileges

Syndicate content