CM_Request_Device_Eject (setupapi)
Last changed: -212.44.20.206

.
Summary
TODO - a short description

C# Signature:

    [DllImport("setupapi.dll", CharSet = CharSet.Auto)]
    static extern int CM_Request_Device_Eject(IntPtr devinst, ref PNP_VETO_TYPE pVetoType, System.Text.StringBuilder pszVetoName, int ulNameLength, int ulFlags);

VB Signature:

Declare Function CM_Request_Device_Eject Lib "setupapi.dll" (TODO) As TODO

User-Defined Types:

    enum PNP_VETO_TYPE : int
    {
        PNP_VetoTypeUnknown,
        PNP_VetoLegacyDevice,
        PNP_VetoPendingClose,
        PNP_VetoWindowsApp,
        PNP_VetoWindowsService,
        PNP_VetoOutstandingOpen,
        PNP_VetoDevice,
        PNP_VetoDriver,
        PNP_VetoIllegalDeviceRequest,
        PNP_VetoInsufficientPower,
        PNP_VetoNonDisableable,
        PNP_VetoLegacyDriver,
    }

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

    // Assuming have IntPtr devinst already
    //
    // static readonly int CR_SUCCESS = 0x00000000; // cfgmgr32.h
    // static readonly int DN_REMOVABLE = 0x00004000; // cfg.h

    if (CR_SUCCESS == CM_Get_DevNode_Status(ref status, ref problem, devinst, 0) && (DN_REMOVABLE & status) > 0)
    {
        PNP_VETO_TYPE pnp_veto_type = PNP_VETO_TYPE.PNP_VetoTypeUnknown;
        System.Text.StringBuilder sb = new System.Text.StringBuilder(255);

        bool success = (CR_SUCCESS == CM_Request_Device_Eject(devinst, ref pnp_veto_type, sb, sb.Capacity, 0));
    }

Documentation