Using Win32 functions in Visual FoxPro Image Gallery
Handle and Object
..msdn
CloseHandle
DuplicateHandle
GetHandleInformation
SetHandleInformation
Code examples:
Comparing file times
Copying files as a transacted operation (Vista)
Creating a console window for Visual FoxPro application
Creating a file, then moving it to another destination
Creating a mailslot
Enumerating Processes -- Win9*
Enumerating Processes -- WinNT
How to check whether the system is 32-bit or 64-bit
How to convert a bitmap file to monochrome format (1 bpp)
How to enable the SE_SHUTDOWN_NAME privilege for the application
How to find when the application started
How to make application automatically close all documents it opened
How to prevent users from accessing the Windows Desktop and from switching to other applications
How to run FoxPro application under different user name (impersonating user)
How to set Creation Date/Time for a folder (WinNT)
How to Start a Process as Another User (NT/XP/2K)
How to suspend or hibernate your system
HOWTO: Use the Win32 API to Access File Dates and Times
Locking and unlocking file of a VFP table
Monitoring changes occurring within a directory
Moving shortcut to a specified position on the Windows Desktop
Obtaining I/O counts for the current process
Obtaining names and positions for shortcuts located on the Windows Desktop
Obtaining physical parameters for a drive: sectors, clusters, cylinders...
Passing data records between VFP applications via the Clipboard
Peer-to-peer LAN messenger built with Mailslot API functions
Reading and setting system access privileges for the current process
Reading and setting the priority class values for the current process and thread
Retrieving file information for the VFP executable running
Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)
Setting the date and time that a file was created
Starting external program from VFP and waiting for its termination
Storing content of the Clipboard to a bitmap file
Storing screen shot of a form to bitmap file
Subclassing CommandButton control to create BackColor property
Terminating all running applications from a VFP program
Testing serial ports
Using File Mapping for enumerating files opened by Visual FoxPro
Using GetFileSize
Using InternetSetFilePointer when resuming interrupted download from the Internet
Using mailslots to send messages on the network
Using named pipes for interprocess communication
Using shared memory to exchange data between two FoxPro applications
Using the CreateFile
Using the DeleteFile
Using the Semaphore object
Using the Semaphore object to allow only one instance of VFP application running
Vertical Label control
Reading and setting the priority class values for the current process and thread

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:
The priority of each thread is determined by the following criteria:
  • The priority class of its process
  • The priority level of the thread within the priority class of its process

    The priority class and priority level are combined to form the base priority of a thread. The priority levels range from zero (lowest priority) to 31 (highest priority).
  •  
    #DEFINE PROCESS_QUERY_INFORMATION  1024
    #DEFINE PROCESS_VM_READ            4
    #DEFINE NORMAL_PRIORITY_CLASS      32
    #DEFINE IDLE_PRIORITY_CLASS        64
    #DEFINE HIGH_PRIORITY_CLASS        128
    #DEFINE REALTIME_PRIORITY_CLASS    256
    #DEFINE THREAD_BASE_PRIORITY_MAX   2
     
    DO declare
     
    LOCAL hProcess, hThread
     
    * retrieve a handle to the current process
    hProcess = OpenProcess(;
        BITOR(PROCESS_QUERY_INFORMATION,PROCESS_VM_READ),;
        0, GetCurrentProcessId())
     
    * retrieve a handle (pseudo) to the current thread
    * no need to release this handle through the CloseHandle function
    hThread = GetCurrentThread()
     
    IF hProcess <> 0
        ? "Current process priority:", GetPriorityClass (hProcess)
        ? "Current thread priority:", GetThreadPriority(hThread)
     
        ? "Attempting to change the priority class for the current process:",;
            SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS)
     
        ? "Attempting to change the priority class for the current thread:",;
            SetThreadPriority(hThread, THREAD_BASE_PRIORITY_MAX)
     
        ? "Changed process priority:", GetPriorityClass (hProcess)
        ? "Changed thread priority:", GetThreadPriority(hThread)
     
        = CloseHandle(hProcess)
    ENDIF
     
    PROCEDURE declare
        DECLARE INTEGER GetCurrentThread IN kernel32
        DECLARE INTEGER GetCurrentProcessId IN kernel32
        DECLARE INTEGER CloseHandle IN kernel32 INTEGER hObject
        DECLARE INTEGER GetThreadPriority IN kernel32 INTEGER hThread
        DECLARE INTEGER GetPriorityClass IN kernel32 INTEGER hProcess
     
        DECLARE INTEGER SetThreadPriority IN kernel32;
            INTEGER hThread, INTEGER nPriority
     
        DECLARE INTEGER OpenProcess IN kernel32;
            INTEGER dwDesiredAccess,;
            INTEGER bInheritHandle, INTEGER dwProcId
     
        DECLARE INTEGER SetPriorityClass IN kernel32;
            INTEGER hProcess, INTEGER dwPriorityClass
     
     
     

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    1781 bytes  
    Created: 2001-12-17 23:11:54  
    Modified: 2008-04-24 11:07:05  
    Visits in 7 days: 134  
    Listed functions:
    CloseHandle
    GetCurrentProcessId
    GetCurrentThread
    GetPriorityClass
    GetThreadPriority
    OpenProcess
    SetPriorityClass
    SetThreadPriority
    Printer friendly API declarations
    My comment:
    A handle to the current process is retrieved through the OpenProcess function.

    Another option available is using the GetCurrentProcess function. This function returns not exactly a handle, but rather a pseudo-handle. Which can be used same way as the real one, saving the CloseHandle call.
    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 (184.73.7.143)
    3 sec.Example: 'Using Video Capture: enumerating installed capture drivers'
    26.28 min.Function: 'AVIStreamInfo'
    Function group: 'Windows Multimedia'
    26.33 min.Function: 'PostMessage'
    26.38 min.Example: 'How to put a horizontal text scrolling on the form (a news line)'
    1.65 hrs.Example: 'Enumerating the subkeys for a given registry key'
    1.66 hrs.Function: 'SetPriorityClass'
    1.98 hrs.Example: 'Custom FTP Class for Visual FoxPro application'
    1.99 hrs.Example: 'Subclassing CommandButton control to create BackColor property'
     Example: 'Enumerating printer drivers installed'
    3.92 hrs.Example: 'How to empty the Recycle Bin'
    Google
    Advertise here!