Using Win32 functions in Visual FoxPro Image Gallery
Kernel Transaction Manager
CommitTransaction
CreateTransaction
RollbackTransaction
Code examples:
Copying files as a transacted operation (Vista)
Copying files as a transacted operation (Vista)

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:
Windows Vista offers transaction protection for various file operations: create, delete, copy, move and more.

See also:
  • Displaying standard progress dialog box when copying files
  • Deleting file into the Recycle Bin
  •  
    #DEFINE INVALID_HANDLE_VALUE -1
    #DEFINE COPY_FILE_FAIL_IF_EXISTS 0x00000001
    #DEFINE COPY_FILE_OPEN_SOURCE_FOR_WRITE 0x00000004
     
    DO declare
     
    LOCAL hTrans
    hTrans = CreateTransaction(0, 0, 0, 0, 0, 1000, NULL)
    IF hTrans = INVALID_HANDLE_VALUE
        ? "CreateTransaction call failed:", GetLastError()
        RETURN
    ENDIF
     
    LOCAL cSrc, cDst, nResult
    cSrc = "c:\temp\test.txt"
    cDst = "c:\temp\test1.txt"
     
    nResult = CopyFileTransacted(cSrc, cDst, 0, 0, 0,;
        BITOR(COPY_FILE_FAIL_IF_EXISTS,;
        COPY_FILE_OPEN_SOURCE_FOR_WRITE),;
        hTrans)
     
    IF nResult = 0
        ? "CopyFileTransacted call failed:", GetLastError()
        = RollbackTransaction(m.hTrans)
    ELSE
        = CommitTransaction(m.hTrans)
    ENDIF
     
    = CloseHandle(hTrans)
    * end of main
     
    PROCEDURE declare
        DECLARE INTEGER CopyFileTransacted IN kernel32;
            STRING lpExistingFileName, STRING lpNewFileName,;
            INTEGER lpProgressRoutine, INTEGER lpData,;
            INTEGER pbCancel, INTEGER dwCopyFlags,;
            INTEGER hTransaction
     
        DECLARE INTEGER CloseHandle IN kernel32;
            INTEGER hObject
     
        DECLARE INTEGER CommitTransaction IN KtmW32;
            INTEGER TransactionHandle
     
        DECLARE INTEGER RollbackTransaction IN KtmW32;
            INTEGER TransactionHandle
     
        DECLARE INTEGER GetLastError IN kernel32
     
        DECLARE INTEGER CreateTransaction IN KtmW32;
            INTEGER lpTransactionAttributes, INTEGER UOW,;
            INTEGER CreateOptions, INTEGER IsolationLevel,;
            INTEGER IsolationFlags, INTEGER Timeout,;
            STRING @Description
     

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    1451 bytes  
    Created: 2008-12-04 16:08:39  
    Modified: 2010-07-30 08:32:08  
    Visits in 7 days: 48  
    Listed functions:
    CloseHandle
    CommitTransaction
    CopyFileTransacted
    CreateTransaction
    GetLastError
    RollbackTransaction
    Printer friendly API declarations
    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 (23.22.76.170)
    12.23 hrs.Function: 'DrawDibDraw'
     Function: 'WSACloseEvent'
    Function group: 'Windows Sockets 2 (Winsock)'
    12.9 hrs.Function: 'IsIconic'
    14.79 hrs.Function: 'JetCloseTable'
    Function group: 'Extensible Storage Engine (ESE, Jet Blue)'
    16.52 hrs.Function: 'waveInGetDevCaps'
     Example: 'Using File Mapping for enumerating files opened by Visual FoxPro'
    18.14 hrs.Example: 'Creating the Open dialog box to specify the drive, directory, and name of a file to open'
     Function: 'GdiSetBatchLimit'
    Function group: 'Painting and Drawing'
    20.98 hrs.Example: 'Shortcut Menu Class'
     Function: 'NetShareAdd'
    Function group: 'Network Management'
    Google
    Advertise here!