Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Using FtpCommand
Dial the Net Automatically
Displaying the associated icons and descriptions for files and folders
Drawing standard Windows icons
Get the power status of your laptop computer
Retrieving current settings for an ODBC connection
Retrieving file information for the VFP executable running
Accessing examples contained in this reference from a VFP application
Disconnecting USB Mass Storage Device programmatically
Storing registration key in the resources of an executable file
Winsock: reading and setting socket options
Winsock: retrieving the standard host name and IP address for the local machine
How to retrieve network parameters for the local computer (including Host name, Domain name, and DNS Server)
How to set Creation Date/Time for a folder (WinNT)
Power capabilities of the system: battery, UPS, sleep and hibernation modes, processor throttling
Reading VFP settings from the Windows Registry
Uploading file to the FTP server using InternetWriteFile
Disabling drawing in the VFP form
How to make the caption of a VFP application flashing in the Windows task bar
Reading header information from AVI file
Retrieving configuration information for the specified workstation (Win2000/XP)
Starting external program from VFP and waiting for its termination
Using the RestartDialog function -- restarting Windows
Attaching menu to a top-level form
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: 62  
    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 (50.19.155.235)
    3 sec.Function: 'SetFilePointerEx'
    Function group: 'File Management'
    7.1 hrs.Example: 'Displaying the associated icons and descriptions for files and folders'
     Example: 'Using Beep and Sleep functions to make the old tin buzz sing (WinNT only?)'
     Example: 'How to create MD-5 and SHA-1 hash values from a string'
    8.4 hrs.Example: 'Using an Event Object. Part A: running an application that creates an Event object'
     Function: 'AlphaBlend'
    11.78 hrs.Example: 'How to view system icons for the classes installed on the local machine'
     Example: 'How to print FoxPro form -- II'
    12.94 hrs.Example: 'Winsock: how to retrieve a service information corresponding to a port'
    13.74 hrs.Function: 'DeletePort'
    Google
    Advertise here!