code

Check for active Internet connection

The InternetCheckConnection function can be used to check for an active connection to the internet. It requires an URL to a fast and reliable web site as the first parameter.

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

#DEFINE  FLAG_ICC_FORCE_CONNECTION 1
 
DECLARE Long InternetCheckConnection IN Wininet.dll String Url, Long dwFlags, Long Reserved
 
* Fast and reliable web site
lcUrl = "http://www.google.com"
IF InternetCheckConnection(lcUrl, FLAG_ICC_FORCE_CONNECTION, 0) <> 0

Retrieving Extended File Properties

When you right-click a file in Windows Explorer and select Properties from the shortcut menu, a dialog box displays basic properties for that file, including such things as file name, file size, and the file creation, last access, and last modification dates. In addition to these basic properties, the Windows operating system also tracks a number of extended file properties. These properties are typically hidden; to display them in Windows Explorer, you must click View, click Choose Details, and then select the desired properties from the resulting dialog box.

The Shell Folder object includes a GetDetailsOf method that allows to access these extended properties. A ParseName method can be used to retrieve a FolderItem object that represents a specified item.

AT and RAT UDFs - Search a character expression for the occurrence of another character expression

T-SQL has CHARINDEX and PATINDEX functions that return the position of one character expression in another. The ufn_AT and ufn_RAT functions add the ability to search for specified occurrences and to search from right to left.

Flash Application window or/and Taskbar button

Sometimes it's necessary to attract a user attention to an application that is currently not active. Such application can utilize FlashWindowEx Function. The Windows API support class is used to handle Windows API structures.

Lowering memory usage by application

The working set of a process is the set of memory pages currently visible to the process in physical RAM memory. These pages are resident and available for an application to use without triggering a page fault. While increasing your working set size can reduce paging for your application, it can adversely affect the system performance.

VFP is know in using all the memory it can get. One of proactive steps in reducing memory usage is limiting VFP buffers size using SYS(3050) - Set Buffer Memory Size. It's a good idea to empty the working set when your application goes into a wait state. It can be done by calling EmptyWorkingSet Function or SetProcessWorkingSetSize Function and uses GetCurrentProcess Function.

Formating a date as a date string for a locale specified

The GetDateFormat Windows API function formats a date as a date string for a Locale Identifier specified. The formatting is controlled either by flags or by the formatting string, if provided. The function accepts SYSTEMTIME Structure as one of its parameters.

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

#DEFINE LOCALE_USER_DEFAULT	0x400
#DEFINE DATE_LONGDATE		0x2

Simple line wrap for a message box

When message is too long VFP message box provides a line wrap but it stretches out almost of the with of the screen. It's easy to implement a line wrap to specified number of characters using VFP memo handling capabilities.

Retrieving Printer Capabilities

In Enumerating printer forms article the DeviceCapabilities function is used to mark print forms supported by particular printer. It can be used to retrieve other printer capabilities as well.

Verify ActiveX presence and registration

An ActiveX installation on PC can be verified by finding its ProgID from OleClass property in the registry.

Syndicate content