Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to play MIDI notes
Power capabilities of the system: battery, UPS, sleep and hibernation modes, processor throttling
Exporting DLL icon resources as .ICO files
Obtaining names of local and global groups for current user (WinNT/XP/2K)
System and Local Time values
Displaying icons in the system tray (VFP9)
Drawing a rectangle using Windows regular edges and borders
Obtaining some properties for the Windows desktop using the GetWindowPlacement function
Drawing Windows frame controls using the DrawFrameControl function
How to block the ALT+TAB shortcut (WinXP)
A client for testing non-blocking Winsock server
A procedure for setting file times
How to delete all print jobs for a printer
Using GetFileSize
Windows Shell Icons displayed and exported to ICO files (Vista)
Adding printer to the list of supported printers for the specified server
Changing system colors
Extended MessageBox Class
GDI+: saving image of FoxPro form to graphics file (BMP, GIF, JPG, PNG, TIF)
Obtaining names and positions for shortcuts located on the Windows Desktop
Retrieving a universal form for the drive-based path for a network resource
Displaying OS Memory Status
Enumerating servers of the specified type (e.g. SQL Server) in the primary domain
How to enable the SE_SHUTDOWN_NAME privilege for the application
Using Shell for performing operations on files

User rating: 10/10 (1 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:
Select valid file and directory names before testing this code.

Other code samples you might be interested in:
  • Running external applications from VFP using WinExec
  • Running external applications from VFP using CreateProcess
  • Running an external program from FoxPro and waiting for its termination
  • How to Start a Process as Another User (NT/XP/2K)

  •  
    #DEFINE SW_SHOWNORMAL 1
    #DEFINE SW_SHOWMINIMIZED 2
    #DEFINE SW_SHOWMAXIMIZED 3 
     
        DECLARE INTEGER GetSystemDirectory IN kernel32;
            STRING @lpBuffer, INTEGER nSize
     
        DECLARE INTEGER ShellExecute IN shell32;
            INTEGER hWindow, STRING lpOperation,;
            STRING lpFile, STRING lpParameters,;
            STRING lpDirectory, INTEGER nShowCmd
     
        * opens data files with their associated applications
    *    = ShellExecute(0, "open", "c:\aa\index.mdb", "", "", SW_SHOWMAXIMIZED)
    *    = ShellExecute(0, "open", "c:\aa\aa.bmp", "", "", SW_SHOWMAXIMIZED)
    *    = ShellExecute(0, "open", "c:\aa\lacrymosa.mp3", "", "", SW_SHOWMAXIMIZED)
    *    = ShellExecute(0, "open", "c:\aa\mkart.doc", "", "", SW_SHOWMAXIMIZED)
    *    = ShellExecute(0, "open", "c:\aa\aa.txt", "", "", SW_SHOWMAXIMIZED)
     
        * opens a folder
    *    = ShellExecute(0, "explore", "c:\Temp", "", "", SW_SHOWMAXIMIZED)
     
        * open Search window starting from the specified directory
    *    = ShellExecute(0, "find", "", "", getSysDir(), SW_SHOWMAXIMIZED)
     
        * prints the text file using the associated application
    *    = ShellExecute(0, "print", "c:\aa\index.txt", "", "", SW_SHOWMAXIMIZED)
     
        * accessing a site on the Internet
    *    = ShellExecute(0, "open", "http://www.microsoft.com/",;
    *        "", "", SW_SHOWMAXIMIZED)
     
        * sending an email: 
        * Mike Lewis, http://www.ml-consult.demon.co.uk/foxst-22.htm
     
        LOCAL lcMail
        lcMail = "mailto:buddy1@somwhere.com" +;
            "?CC=buddy2@somwhere.com&Subject=Meet for lunch" +;
            "&Body=Please join me for a sandwich at noon."
     
        = ShellExecute(0, "open", lcMail, "", "", SW_SHOWNORMAL)
     
    FUNCTION GetSysDir
        lpBuffer = SPACE(250) 
        nSizeRet = GetSystemDirectory(@lpBuffer, Len(lpBuffer)) 
    RETURN SUBSTR(lpBuffer, 1, nSizeRet) 
     
     
     

    User rating: 10/10 (1 votes)
    Rate this code sample:
    • ~
    1708 bytes  
    Created: 2001-08-06 12:00:00  
    Modified: 2008-10-03 15:25:57  
    Visits in 7 days: 58  
    Listed functions:
    GetSystemDirectory
    ShellExecute
    Printer friendly API declarations
    My comment:
    There is one more action type -- EDIT.

    For some actions failed, GetLastError returns() value 1155, that means ERROR_NO_ASSOCIATION | No application is associated with the specified file for this operation..

    Links:
    HOWTO: Use ShellExecute to Launch Associated File (32-bit) (Q170918).

    Tip 168: Using the ShellExecute Function to Print Files.

    An easy way sending emails from a Visual FoxPro application -- an article of Mike Lewis.

    VBNet: Sending Large Emails via ShellExecute.

    #kwd: sln_sendemail.
    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:
    A.M. | 2007-01-24 09:06:50
    Include "printto" verb:
    lretval=ShellExecute(0, "Printto", (lfilename), ["]+SET('PRINTER',3)+["], 0,1)

    http://www.universalthread.com/wconnect/wc.dll?2,15,1188377

    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 (107.22.156.205)
    2.79 hrs.Function: 'midiOutGetDevCaps'
     Function: 'waveOutGetErrorText'
    Function group: 'Windows Multimedia'
    2.8 hrs.Example: 'How to view icons stored in executable files (Icon Viewer) - II'
    Language: 'Visual FoxPro'
    4.18 hrs.Function: 'CopyImage'
    Function group: 'Resource'
     Example: 'Basic Volume information'
    7.33 hrs.Function: 'SetupDiGetClassImageListEx'
    13.71 hrs.Example: 'Number of clipboard formats available'
     Example: 'How to print FoxPro form'
    16.69 hrs.Example: 'How to extract frames from AVI files'
     Example: 'Getting a bit more than the _CLIPTEXT offers'
    Google
    Advertise here!