kerneliocontrol (coredll)
Last changed: Zeno[nu]-62.216.23.169

.
Summary
TODO - a short description

C# Signature:

[DllImport("coredll.dll", SetLastError=true)]
internal static extern bool KernelIoControl(int dwIoControlCode, byte[] inBuf, int inBufSize, byte[] outBuf, int outBufSize, ref int bytesReturned);

VB Signature:

Declare Function KernelIoControl Lib "coredll.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

Taken from openNetCF in OpenNETCF.Win32.Core

Tips & Tricks:

Please add some!

Sample Code:

C# code, A Sample of soft resetting the device:

#region declares for softreset (KernelIOControl)

    // Control Code flags
    private const uint FILE_DEVICE_UNKNOWN = 0x00000022;
    private const uint FILE_DEVICE_HAL = 0x00000101;
    private const uint FILE_DEVICE_CONSOLE = 0x00000102;
    private const uint FILE_DEVICE_PSL = 0x00000103;
    private const uint METHOD_BUFFERED = 0;
    private const uint METHOD_IN_DIRECT = 1;
    private const uint METHOD_OUT_DIRECT = 2;
    private const uint METHOD_NEITHER = 3;
    private const uint FILE_ANY_ACCESS = 0;
    private const uint FILE_READ_ACCESS = 0x0001;
    private const uint FILE_WRITE_ACCESS = 0x0002;

    private static uint CTL_CODE(uint DeviceType, uint Function, uint Method, uint Access)
        {
            return ((DeviceType << 16) | (Access << 14) | (Function << 2) | Method);
        }

        /// <summary>
        /// This function provides the kernel with a generic I/O control for
        /// carrying out I/O operations.
        /// </summary>
        /// <param name="dwIoControlCode">I/O control code, which should support the
        /// OAL I/O controls. For a list of these I/O controls, see Supported
        /// OAL APIs.</param>
        /// <param name="lpInBuf">Pointer to the input buffer.</param>
        /// <param name="nInBufSize">Size, in bytes, of lpInBuf.</param>
        /// <param name="lpOutBuf">Pointer to the output buffer.</param>
        /// <param name="nOutBufSize">Maximum number of bytes that can be returned in
        /// lpOutBuf.</param>
        /// <param name="lpBytesReturned">Address of a DWORD that receives the size,
        /// in bytes, of the data returned.</param>
        /// <returns>TRUE indicates success; FALSE indicates failure.</returns>
        [DllImport("Coredll.dll")]
    private extern static uint KernelIoControl
        (
            uint dwIoControlCode,
            IntPtr lpInBuf,
            uint nInBufSize,
            IntPtr lpOutBuf,
            uint nOutBufSize,
            ref uint lpBytesReturned
        );
    #endregion

    /// <summary>
    /// the method needed to be called to actually reset the device.
    /// </summary>
    public static void resetDevice()
    {
        uint bytesReturned = 0;
        uint IOCTL_HAL_REBOOT = CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS);
        KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0, IntPtr.Zero, 0, ref bytesReturned);
    }


Documentation