Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Pocket PC: creating new database in the Object Store and copying Contacts Database records into it
Simple MAPI: how to resolve a name to unique address list entry
Using MessageBeep
Clipping mouse cursor area
How to release and renew a lease on an IP address previously obtained through Dynamic Host Configuration Protocol (DHCP)
Reading current hardware profile
Saving available locale records into a cursor
Time in milliseconds represented as string (e.g. 1 hour 24 min 36 sec)
Using an Event Object. Part B: running an application responding to events
Using the FindMediaType function
Converting long file names to the short format and vice versa
Current System information
Retrieving graphic capabilities of your display
Retrieving the priority class for the current process
WAV file recorder
Pocket PC: enumerating mounted database volumes and databases in the Object Store
Reading Internet Query options
Retrieveing general information about the driver and data source associated with an ODBC connection
Retrieving list of Global Atom names
Retrieving the command line for the VFP session
Retrieving the state of your Internet connection
Scanning a hierarchy of child windows down from the Windows Desktop
Terminating VFP application using the FatalAppExit
Using GetSysColor
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: 58  
    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-2013 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.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.242.233.11)
    39.6 min.Example: 'Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)'
    39.65 min.Function: 'RegDeleteKey'
    2.05 hrs.Example: 'How to enumerate terminal servers within the specified Windows domain'
     Function: 'WindowFromDC'
    5.14 hrs.Example: 'Displaying animated images on FoxPro form with BitBlt and StretchBlt functions'
    5.24 hrs.Function: 'SQLDisconnect'
    Function group: 'ODBC API'
     Function: 'LockResource'
    Function group: 'Resource'
     Function: 'GetCurrentHwProfile'
    Function group: 'System Information'
    6.76 hrs.Example: 'How to put a vertical text scrolling on the form (a movie cast)'
    7.18 hrs.Function: 'CreateDC'
    Function group: 'Device Context'
    Google
    Advertise here!