CreateFile ()

From ISXKB

(Difference between revisions)
Jump to: navigation, search
(Declaration)
Current revision (10:59, 4 September 2009) (view source)
m
 
Line 46: Line 46:
*[[ReadFile ()]]
*[[ReadFile ()]]
*[[WriteFile ()]]
*[[WriteFile ()]]
 +
*[[GetFileTime ()]]
[[Category:Windows API function calls with Inno Setup]]
[[Category:Windows API function calls with Inno Setup]]

Current revision

This article shows how to use the Windows API function CreateFile with Inno Setup. This function is sometimes quite useful because Inno Setup's file handling functions don't support security or any kind of locking/sharing mechanism.

Contents

Declaration

The following declaration is required in a [Code] section:

const
    // Some constants for CreateFile ().
    GENERIC_READ           = $80000000;
    GENERIC_WRITE          = $40000000;
    GENERIC_EXECUTE        = $20000000;
    GENERIC_ALL            = $10000000;
    FILE_SHARE_READ        = 1;
    FILE_SHARE_WRITE       = 2;
    FILE_SHARE_DELETE      = 4;
    CREATE_NEW             = 1;
    CREATE_ALWAYS          = 2;
    OPEN_EXISTING          = 3;
    OPEN_ALWAYS            = 4;
    TRUNCATE_EXISTING      = 5;
    FILE_READ_ATTRIBUTES   = $80;
    FILE_WRITE_ATTRIBUTES  = $100;

    // General Win32.
    INVALID_HANDLE_VALUE   = -1;

function CreateFile (
    lpFileName             : String;
    dwDesiredAccess        : Cardinal;
    dwShareMode            : Cardinal;
    lpSecurityAttributes   : Cardinal;
    dwCreationDisposition  : Cardinal;
    dwFlagsAndAttributes   : Cardinal;
    hTemplateFile          : Integer
): Integer;
 external 'CreateFileA@kernel32.dll stdcall';

CreateFile () at MSDN

Examples

Only one installer instance

See Also

Personal tools
Ads: