Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Custom GDI+ class
Splash Screen for the VFP application
Vertical Label control
Displaying dimmed window behind VFP top-level form
Subclassing CommandButton control to create BackColor property
Storing content of the Clipboard to a bitmap file
How to make a VFP form fading out when released (GDI version)
Printing text with the Escape function
How to put a vertical text scrolling on the form (a movie cast)
How to put a horizontal text scrolling on the form (a news line, marquee)
Storing screen shot of a form to bitmap file
How to play AVI file on the _screen
Custom FTP Class for Visual FoxPro application
Bitmap Class for Visual FoxPro application
Enumerating devices installed on the local machine
Playing WAV sounds simultaneously
How to view icons stored in executable files (Icon Viewer) - II
Enumerating Processes -- WinNT
Obtaining names and positions for shortcuts located on the Windows Desktop
Passing data records between VFP applications via the Clipboard
CryptoAPI: Collection of Providers class
Monitoring clipboard content changes (VFP9)
Copying picture of the active form to the Clipboard using Enhanced Metafile API functions
Displaying system dialog that selects a folder
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
Versions:
click to open
Before you begin:
See also:
  • Using the Semaphore object to allow only one instance of VFP application running
  • #DEFINE WAIT_OBJECT_0 0
    #DEFINE STATUS_TIMEOUT 0x0102
    
    DO declare
    
    LOCAL hSmp, lnInc
    
    lnInc = 3
    hSmp = CreateSemaphore(0, lnInc, lnInc, "TestSmp")
    
    IF hSmp = 0
    * 87 = ERROR_INVALID_PARAMETER
        ? "Error:", GetLastError()
        RETURN
    ENDIF
    
    ? "Semaphore handle:", hSmp
    ? "Initial count:", lnInc
    ?
    ? "Decrementing the count..."
    FOR ii=1 TO 10
        dwWaitResult = WaitForSingleObject(hSmp, 0)
        ? "dwWaitResult:", _status(dwWaitResult)
    ENDFOR
    
    ?
    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)
    ENDFOR
    
    = CloseHandle(hSmp)
    * end of main
    
    FUNCTION _status(lnWaitResult)
        DO CASE
        CASE lnWaitResult = WAIT_OBJECT_0
            RETURN "WAIT_OBJECT_0"
        CASE lnWaitResult = STATUS_TIMEOUT
            RETURN "STATUS_TIMEOUT"
        OTHER
            RETURN "Unknown type: " + LTRIM(STR(lnWaitResult))
        ENDCASE
    
    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: 147  
    Listed functions:
    CloseHandle
    CreateSemaphore
    GetLastError
    OpenSemaphore
    ReleaseSemaphore
    WaitForSingleObject
    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  
    FreeTranslation.com 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.38), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (23.22.136.56)
    16 sec.Function: 'ChooseColor'
    31 sec.Function: 'CryptUnprotectData'
    44 sec.Function: 'GetIconInfo'
    1 min.
    Function group: 'COM'
    1.27 min.Function: 'CreateURLMonikerEx'
    1.53 min.Function: 'TaskDialogIndirect'
    1.82 min.Function: 'HeapReAlloc'
    2.08 min.Function: 'GetPhysicalMonitorsFromHMONITOR'
    2.38 min.Function: 'GetLocalTime'
    2.65 min.Function: 'GetDeviceCaps'
    Google
    Advertise here!