Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to play MIDI notes
How to retrieve the size of a remote file (FTP)
Listing child windows for the Windows desktop
Obtaining a handle to the desktop associated with the calling thread
Reading security permissions for NTFS files and folders
Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window
A class that encrypts and decrypts files using Cryptography API Functions
Creating the Open dialog box to specify the drive, directory, and name of a file to open
Uploading local file to FTP server with FtpPutFile
Using FtpCommand
Using InternetSetFilePointer when resuming interrupted download from the Internet
Retrieving information about the specified icon
Winsock: retrieving information from a host database for a given host name
Building a tree of subdirectories for a given path using FindFile functions
How to create transparent areas inside a form -- punching holes in the form
Reading list of folders and files on FTP server
Comparing dimensions of the VFP main window with _SCREEN properties
GDI+: Drawing a Pie Chart
How to delete IE cookies, clear IE history and delete files in Temporary Internet Files directory
How to register custom Event Log source
Monitoring changes occurring within a directory
Reading and setting the priority class values for the current process and thread
Uploading file to the FTP server using InternetWriteFile
Using FrameRgn for displaying system colors
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
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)

        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", "",;
    *        "", "", SW_SHOWMAXIMIZED)
        * sending an email: 
        * Mike Lewis,
        LOCAL lcMail
        lcMail = "" +;
            "? 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: 44  
    Listed functions:
    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..

    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 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),15,1188377

    Copyright 2001-2016 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.6.33), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (
    1.67 min.Example: 'Pocket PC: base class'
    Advertise here!