Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Custom GDI+ class
Obtaining names and positions for shortcuts located on the Windows Desktop
Printing Image File, programmatically set print page orientation to landscape
GDI+: Implementing image scrolling with inertia
How to change display settings: screen resolution, screen refresh rate
Displaying dimmed window behind VFP top-level form
How to load a user profile
Browsing Windows Known Folders (Special Folders)
Displaying icons in the system tray (VFP9)
Monitoring clipboard content changes (VFP9)
Moving shortcut to a specified position on the Windows Desktop
GDI+ fun: roach-infested desktop
Custom FTP Class for Visual FoxPro application
Splash Screen for the VFP application
Detecting changes in connections to removable drives (VFP9)
GDI+: Creating thumbnails to preview images in a directory
Storing content of the Clipboard to a bitmap file
How to put a horizontal text scrolling on the form (a news line, marquee)
Placing On-screen Alert on top of all windows
Pocket PC: custom RAPI class for operating with files and folders on mobile device
GDI+: Scrolling through large image using the mouse
GDI+: sending image of FoxPro form to printer
Compressing and decompressing files with Windows API Runtime Library routines
How to put a vertical text scrolling on the form (a movie cast)
Using the Semaphore object

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
click to open
Before you begin:
See also:
  • Using the Semaphore object to allow only one instance of VFP application running
    DO declare
    LOCAL hSmp, lnInc
    lnInc = 3
    hSmp = CreateSemaphore(0, lnInc, lnInc, "TestSmp")
    IF hSmp = 0
        ? "Error:", GetLastError()
    ? "Semaphore handle:", hSmp
    ? "Initial count:", lnInc
    ? "Decrementing the count..."
    FOR ii=1 TO 10
        dwWaitResult = WaitForSingleObject(hSmp, 0)
        ? "dwWaitResult:", _status(dwWaitResult)
    lnInc = 2
    ? "Incrementing the count by " + LTRIM(STR(lnInc))
    = ReleaseSemaphore(hSmp, lnInc, 0)
    ? "Decrementing the count..."
    FOR ii=1 TO 5
        dwWaitResult = WaitForSingleObject(hSmp, 0)
        ? "dwWaitResult:", _status(dwWaitResult)
    = CloseHandle(hSmp)
    * end of main
    FUNCTION _status(lnWaitResult)
        DO CASE
        CASE lnWaitResult = WAIT_OBJECT_0
            RETURN "WAIT_OBJECT_0"
        CASE lnWaitResult = STATUS_TIMEOUT
            RETURN "Unknown type: " + LTRIM(STR(lnWaitResult))
    PROCEDURE declare
        DECLARE INTEGER GetLastError IN kernel32
        DECLARE INTEGER CloseHandle IN kernel32 INTEGER hObject
        DECLARE INTEGER CreateSemaphore IN kernel32;
            INTEGER lcSmAttr, INTEGER lInitialCount,;
            INTEGER lMaximumCount, STRING lpName
        DECLARE INTEGER OpenSemaphore IN kernel32;
            INTEGER dwDesiredAccess, INTEGER bInheritHandle,;
            STRING lpName
        DECLARE INTEGER ReleaseSemaphore IN kernel32;
            INTEGER hSemaphore, INTEGER lReleaseCount,;
            INTEGER @ lpPreviousCount
        DECLARE INTEGER WaitForSingleObject IN kernel32;
            INTEGER hHandle, INTEGER dwMilliseconds

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    1582 bytes  
    Created: 2001-07-12 12:00:00  
    Modified: 2005-12-12 11:23:37  
    Visits in 7 days: 106  
    Listed functions:
    Printer friendly API declarations
    My comment:
    A semaphore object is a synchronization object that maintains a count between zero and a specified maximum value.

    The count is decremented each time a thread completes a wait for the semaphore object and incremented each time a thread releases the semaphore

    When the count reaches zero, no more threads can successfully wait for the semaphore object state to become signaled.

    The state of a semaphore is set to signaled when its count is greater than zero, and nonsignaled when its count is zero.
    Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.

    Copyright 2001-2017 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.37), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (
    6 sec.Function: 'Process32First'
    11 sec.Function: 'PlaySound'
    15 sec.Function: 'PathFileExists'
    20 sec.Function: 'CeReadRecordProps'
    25 sec.Function: 'UuidCreateSequential'
    31 sec.Function: 'mixerGetDevCaps'
    37 sec.Function: 'GetSysColorBrush'
    42 sec.
    Function group: 'PnP Configuration Manager'
    48 sec.Function: 'GetDeviceCaps'
    54 sec.Function: 'GlobalAlloc'
    Advertise here!