Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Sending a standard message with one or more attached files using default email client
How to create MD-5 and SHA-1 hash values from a string
Using Month Calendar Control (VFP9, Comctl32.dll)
Accessing Adobe Reader 7.0 main menu from VFP application
How to play MIDI notes
Winsock: connecting to a news server (NNTP, port 119)
How to display picture stored in enhanced-format metafile (*.emf)
OS version and revision
Retrieving file information for the VFP executable running
Storing screen shot of a form to bitmap file
Creating a window using CreateWindowEx function
GDI+: how to make VFP controls visually shake and shudder
How to prevent users from accessing the Windows Desktop and from switching to other applications
WAV file player
Getting a bit more than the _CLIPTEXT offers
Loading a string resource from an executable file
Using Beep and Sleep functions to make the old tin buzz sing (WinNT only?)
Using Common Controls: the Header Control
Using InternetSetFilePointer when resuming interrupted download from the Internet
How to upload a local file to FTP server using FtpPutFile
Reading entries from Event logs
Class for sound recording
Disconnecting USB Mass Storage Device programmatically
Obtaining names and positions for shortcuts located on the Windows Desktop
Displaying standard progress dialog box when copying files

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
Before you begin:
If you`ve been thinking about retiring ageing VFP commands COPY FILE and RENAME then give this code a try.



See also:
  • How to remove a directory that is not empty
  •  
      Members area. Log in to view this example.
     
      User name:
      Password:
     
     
      Forgot your password?
     
      Sign up for
    the Membership
     
     


    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    7057 bytes  
    Created: 2006-03-07 14:33:18  
    Modified: 2011-12-10 09:20:22  
    Visits in 7 days: 97  
    Listed functions:
    GlobalAlloc
    GlobalFree
    GlobalSize
    SHFileOperation
    Printer friendly API declarations
    My comment:
    The SHFileOperation copies, deletes and moves a file or multiple files. It requires a single parameter that points to a SHFILEOPSTRUCT structure. The structure has to be populated before calling the function.

    Most of the SHFILEOPSTRUCT members are easy to populate except may be pFrom and pTo since they are pointers to strings with no direct support in VFP for this kind of objects. Class PChar inside the code handles string pointers. It allocates and releases memory blocks and moves data between VFP strings and an address in memory.

    A variety of flags the fFlags member can take provides great flexibility. For example, in a single SHFileOperation call a group of files can be copied not to just one but to several destinations. The process is accompanied with familiar OS dialogs showing the progress or sending a reminder when existing file is about to be replaced.

    * * *
    The Shell is as usual brief and efficient. The following code copies all files from the source folder to the target folder. Test with care:

    LOCAL oShell, oSrcFolder, oDstFolder

    oShell = CREATEOBJECT("Shell.Application")
    oSrcFolder = oShell.NameSpace("c:\temp1")
    oDstFolder = oShell.NameSpace("c:\temp")

    IF VARTYPE(oDstFolder)="O" AND VARTYPE(oSrcFolder.Items)="O"
            oDstFolder.CopyHere(oSrcFolder.Items)
    ENDIF
    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:
    Craig Bailey | 2006-03-09 03:20:14
    Small typo - I think line 208 should use buf2dword instead of buf2word (for the This.aborted check.
    Other than that works great.
    A.M. | 2006-03-09 07:59:03
    Craig, thanks! It's fixed now.
    Lewis Harris | 2007-04-13 12:25:00
    I am using VFP 9 SP1 on WINXP and I can't get this to work
    the second namespace command never creates an object it stays null in the debugger.

    any ideas


    LOCAL oShell, oSrcFolder, oDstFolder

    oShell = CREATEOBJECT("Shell.Application")
    oSrcFolder = oShell.NameSpace("c:\temp1")
    oDstFolder = oShell.NameSpace("c:\temp")

    IF VARTYPE(oDstFolder)="O" AND VARTYPE(oSrcFolder.Items)="O"
        oDstFolder.CopyHere(oSrcFolder.Items)
    ENDIF

    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.25.119)
    3 sec.Function: 'OpenClipboard'
    58.87 min.Example: 'Retrieving file information for the VFP executable running'
    1.51 hrs.Function: 'GetProfileString'
     Example: 'GDI+: sending image of FoxPro form to printer'
     Function: 'GetWindowTextLength'
    2.63 hrs.Example: 'Placing a button on the VFP form as a new child window'
     Function: 'InitiateShutdown'
    Function group: 'System Shutdown'
    2.94 hrs.Example: 'Saving HKEY_LOCAL_MACHINE\\Software\\ODBC Registry Entries to an XML file'
     Example: 'GDI+: printing vertical text on VFP reports via generated images (VFP8)'
    4.73 hrs.Example: 'How to display a user-defined icon in the MessageBox dialog'
    Google
    Advertise here!