Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Custom GDI+ class
Capturing keyboard activity of another application with the Raw Input API (VFP9)
How to display Windows On-Screen Keyboard
How to print a bitmap file
Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window
Winsock: sending email messages (SMTP, port 25)
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
System Image List Viewer
Custom HttpRequest class (WinHTTP)
Creating the Save dialog box to specify the drive, directory, and name of a file to save
Printing Image File, programmatically set print page orientation to landscape
How to convert a bitmap file to monochrome format (1 bpp)
The window and its ancestors
Mapping and disconnecting network drives
Using EnumPrinters function to enumerate locally installed printers
How to download a file from the FTP server using FtpGetFile
Custom FTP Class for Visual FoxPro application
Displaying the associated icons and descriptions for files and folders
Displaying icons in the system tray (VFP9)
How to activate Windows Calculator
Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form
Drawing Windows predefined bitmaps using the LoadBitmap functions
Sending email messages with Simple MAPI
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: 64  
    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.16.36.153)
    4 sec.Example: 'HOWTO: Use the Win32 API to Access File Dates and Times'
    1.35 hrs.Example: 'Locking mouse and keyboard input for the VFP application'
     Function: 'waveInStart'
    1.75 hrs.Example: 'Dial the Net Automatically'
     Example: 'How to delete all print jobs for a printer'
     Example: 'Accessing examples contained in this reference from a VFP application'
    6.43 hrs.Function: 'GetActiveWindow'
    6.88 hrs.Article: 'Use Windows API calls to program the MessageBox dialog's timeout interval, button captions, and position. '
     Example: 'Winsock: connecting to a news server (NNTP, port 119)'
    7.9 hrs.Example: 'How to obtain Content-Type value for a file type from the System Registry'
    Google
    Advertise here!