RawDisk

Direct access to disks and protected files from user-mode applications in Windows

RawDisk.Open method

Filter:

Pascal    C++ (DLL/Lib)    C++ (VCL)    C++ (.NET)    C#    VB.NET   

RawDisk     See also    

Overview

Opens raw access to the volume and returns the volume handle

Declaration

[Pascal]
    class function Open( DeviceName : WideString; DesiredAccess : DWORD; LicenseKey : WideString) : THandle;

[C++ (DLL/Lib)]
    static HANDLE Open( unsigned short* DeviceName, unsigned long DesiredAccess, unsigned short* LicenseKey);

[C++ (VCL)]
    static THandle __fastcall Open( WideString DeviceName, unsigned long DesiredAccess, WideString LicenseKey);

[C++ (.NET)]
    static IntPtr Open( String^ DeviceName, long DesiredAccess, String^ LicenseKey);

[C#]
    static IntPtr Open( string DeviceName, int DesiredAccess, string LicenseKey)

[VB.NET]
    Shared Function Open( ByVal DeviceName As String, ByVal DesiredAccess As Integer, ByVal LicenseKey As String) As IntPtr

Parameters

  • DeviceName - Required device name to open (with full path in the windows object namespace). Eg: "\??\C:" or "\??\PhysicalDrive0".
  • DesiredAccess - Desired access, eg. GENERIC_READ | GENERIC_WRITE. The constants are defined in Windows API
  • LicenseKey - The license key. RawDisk doesn't work without the license key (either production or evaluation). You can request the evaluation license key via request form.

Return values

The handle of the device.

Description

Use this method to open the device and obtain it's handle. The obtained handle must be used with ReadFile(), WriteFile() and DeviceIoControl() functions of Windows API.

Once you finished using the direct access to the device, call CloseHandle() Windows API function to release the resources.

The name of the device can be obtained using an utility, offered by Microsoft.
The constants for DesiredAccess parameter can be found in the description of CreateFile() function of Windows API in MSDN Library.

This method doesn't unmount the volume and if you plan to make modifications to raw disk structure, you can corrupt the data (or your changes can be overwritten). Use OpenEx method to unmount the volume before accessing it.

This method can return "Access Denied" error if you try to access logical disk (eg. "\??\C:") without unmounting it. Use OpenEx method to open the partition and unmount it before opening.

If the method fails for whatever reason, an exception with Windows-defined error code is thrown.

See also

OpenEx    

Back to top