Miscellaneous

The following "hidden functions" are available in Visual Patch:

g_OnFileProcessed

 


 

 

g_OnFileProcessed ( 

number ResultCode,

string Filename,

string BackupFilename )

Description

This hidden function is automatically called by the patch at run time if while patching the files, a file is either patched, installed, removed, or skipped.

Some examples of where this advanced function may be useful are:

- The file needs to be added to an existing setup's uninstall so it can be removed if the user uninstalls your software.
- The file needs to be registered for the first time.
- A usage count needs to be incremented if it was installed for the first time.
- Alternate action needs to be taken if a file was skipped.

Note: If you want to use this function, you must define it somewhere in your patch before the patching stage. A good place to add this function to your project is in Global Functions. You can find this dialog by choosing Project > Resources... from the program menu and selecting the Global Functions tab.

Parameters

ResultCode

(number) The result code for the file that was processed. One of the following will be returned:

VALUE

DESCRIPTION

1

Existing file patched.

2

New file installed (a file was "patched" that did not previously exist).

3

Legacy file removed.

4

The file was skipped because a matching target file could not be found on the system.

5

The file was skipped because of an OS or script condition failure.

6

The file was skipped because it was already up to date (matches latest version MD5).

7

The file was skipped because it is protected by Windows File Protection (WFP).

Filename

(string) The fully qualified path and filename of the file that was patched, installed, removed or skipped.

BackupFilename

(string) The fully qualified path and filename of the backup file of the file that was processed. This will be an empty string if a backup was not created.

Returns

Nothing.

 

Example

function g_OnFileProcessed(ResultCode, Filename, BackupFilename)

    local CodeText = "Unknown";
    if ResultCode == 1 then
        CodeText = "Existing file patched";
    elseif ResultCode == 2 then
        CodeText = "New file installed";
    elseif ResultCode == 3 then
        CodeText = "Legacy file deleted";
    elseif ResultCode == 4 then
        CodeText = "File skipped. Matching target not found.";
    elseif ResultCode == 5 then
        CodeText = "File skipped. OS or script condition failure.";
    elseif ResultCode == 6 then
       CodeText = "File skipped. Already up to date.";
    elseif ResultCode == 7 then
        CodeText = "File skipped. Protected target file (WRP).";
    end
    

    local StatusMessage = "Operation: "..CodeText.."\r\n";
    StatusMessage = StatusMessage.."Filename: "..Filename.."\r\n";
    StatusMessage = StatusMessage.."Backup filename: "..BackupFilename;
    Dialog.Message("File Processed",StatusMessage);

end

The above script illustrates the framework for the g_OnFileProcessed function that you can add to your project, such as in the Global Functions area. This example shows a dialog message displaying what was done to the current file being patched by checking the three parameters that are passed into it.