Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "usb" in [All]

Structures

.

     ICC_BAR_CLASSES    = 0x00000004, // toolbar, statusbar, trackbar, tooltips

.

    ' toolbar, statusbar, trackbar, tooltips

.
Summary
.

struct USB_SETUP_PACKET

.

struct USB_DESCRIPTOR_REQUEST

.

   public USB_SETUP_PACKET SetupPacket;

.

Structure USB_DESCRIPTOR_REQUEST

.

const int USB_DEVICE_DESCRIPTOR_TYPE = 1;

.

const int USB_STRING_DESCRIPTOR_TYPE = 3;

.

The USB_DESCRIPTOR_REQUEST structure is always followed by either a USB_STRING_DESCRIPTOR or USB_DEVICE_DESCRIPTOR structure.

.

The use of a a zero-length array at the end of the structure requires that you read and write "off the edge" of the structure. This concept is not well supported in C#/VB.Net so you have make sure that you allocate sufficient buffer space to accommodate a the USB_STRING_DESCRIPTOR or USB_DEVICE_DESCRIPTOR structure.

.

typedef struct _USB_DESCRIPTOR_REQUEST {

.

} USB_DESCRIPTOR_REQUEST, *PUSB_DESCRIPTOR_REQUEST

.
Documentation
[USB_DESCRIPTOR_REQUEST] on MSDN
.

   USB_DESCRIPTOR_REQUEST Request = new USB_DESCRIPTOR_REQUEST();

.

   Request.SetupPacket.wValue = (short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iManufacturer);

.

   if (DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ptrRequest, nBytes, ptrRequest, nBytes, out nBytesReturned, IntPtr.Zero))

.

     USB_STRING_DESCRIPTOR StringDesc = (USB_STRING_DESCRIPTOR)Marshal.PtrToStructure(ptrStringDesc, typeof(USB_STRING_DESCRIPTOR));

.
Summary
Used by DeviceIoControl and IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION to get the Device Descriptor of a device on a port on a USB Hub
.

struct USB_DEVICE_DESCRIPTOR

.

   public ushort bcdUSB;

.

Structure USB_DEVICE_DESCRIPTOR

.

Is often used as a type inside a USB_NODE_CONNECTION_INFORMATION_EX structure, hence the need for the "Pack=1"

.

The values for iManufacturer, iProduct, and iSerialNumber are just indexs that are used by the USB_STRING_DESCRIPTOR request

.

typedef struct _USB_DEVICE_DESCRIPTOR {

.

   USHORT  bcdUSB;

.

} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR ;

.
Documentation
[USB_DEVICE_DESCRIPTOR] on MSDN
.
Summary
Used with DeviceIoControl and IOCTL_GET_HCD_DRIVERKEY_NAME to get the "DriverKeyName" of a USB Root hub
.

struct USB_HCD_DRIVERKEY_NAME

.

Structure USB_HCD_DRIVERKEY_NAME

.

typedef struct _USB_HCD_DRIVERKEY_NAME {

.

} USB_HCD_DRIVERKEY_NAME, *PUSB_HCD_DRIVERKEY_NAME;

.
Documentation
[USB_HCD_DRIVERKEY_NAME] on MSDN
.
Summary
Used with DeviceIoControl and IOCTL_USB_GET_NODE_INFORMATION to get information about a USB Hub
.

struct USB_HUB_DESCRIPTOR

.

Structure USB_HUB_DESCRIPTOR

.

This structure is often nested inside the USB_HUB_INFORMATION structure, hence the need for the "pack=1"

.

typedef struct _USB_HUB_DESCRIPTOR {

.

} USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;

.
Documentation
[USB_HUB_DESCRIPTOR] on MSDN
.
Summary
Used with DeviceIoControl and IOCTL_USB_GET_NODE_INFORMATION to get information about a USB Hub
.

struct USB_HUB_INFORMATION

.

   public USB_HUB_DESCRIPTOR HubDescriptor;

.

Structure USB_HUB_INFORMATION

.

Often nested inside a USB_NODE_INFORMATION structure

.

typedef struct _USB_HUB_INFORMATION {

.

   USB_HUB_DESCRIPTOR HubDescriptor;

.

} USB_HUB_INFORMATION, *PUSB_HUB_INFORMATION;

.
Documentation
[USB_HUB_INFORMATION] on MSDN
.

   USB_NODE_INFORMATION NodeInfo = new USB_NODE_INFORMATION();

.

   NodeInfo.NodeType = (int)USB_HUB_NODE.UsbHub;

.

   if (DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes, out nBytesReturned, IntPtr.Zero))

.

     NodeInfo = (USB_NODE_INFORMATION)Marshal.PtrToStructure(ptrNodeInfo, typeof(USB_NODE_INFORMATION));

.
Summary
Used with DeviceIoControl and IOCTL_USB_GET_NODE_INFORMATION to get information about a USB Hub
.

struct USB_MI_PARENT_INFORMATION

.

Structure USB_MI_PARENT_INFORMATION

.

See USB_NODE_INFORMATION

.
Documentation
[USB_MI_PARENT_INFORMATION] on MSDN
.
Summary
Used with DeviceIoControl and IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME to get the "Driver Key Name" of a device on a USB Hub
.

struct USB_NODE_CONNECTION_DRIVERKEY_NAME

.

Structure USB_NODE_CONNECTION_DRIVERKEY_NAME

.

Identical to the USB_NODE_CONNECTION_NAME structure

.

typedef struct _USB_NODE_CONNECTION_DRIVERKEY_NAME {

.

} USB_NODE_CONNECTION_DRIVERKEY_NAME, *PUSB_NODE_CONNECTION_DRIVERKEY_NAME;

.
Documentation
[USB_NODE_CONNECTION_DRIVERKEY_NAME] on MSDN
.

   USB_NODE_CONNECTION_DRIVERKEY_NAME DriverKey = new USB_NODE_CONNECTION_DRIVERKEY_NAME();

.

   if (DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME, ptrDriverKey, nBytes, ptrDriverKey, nBytes, out nBytesReturned, IntPtr.Zero))

.

     DriverKey = (USB_NODE_CONNECTION_DRIVERKEY_NAME)Marshal.PtrToStructure(ptrDriverKey, typeof(USB_NODE_CONNECTION_DRIVERKEY_NAME));

.
Summary
Used with DeviceIoControl and IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX to retrieve information about a port connection on a USB Hub
.

struct USB_NODE_CONNECTION_INFORMATION_EX

.

   public USB_DEVICE_DESCRIPTOR DeviceDescriptor;

.

Structure USB_NODE_CONNECTION_INFORMATION_EX

.

typedef struct _USB_NODE_CONNECTION_INFORMATION_EX {

.

   USB_DEVICE_DESCRIPTOR  DeviceDescriptor;

.

   USB_CONNECTION_STATUS  ConnectionStatus;

.

   USB_PIPE_INFO  PipeList[0];

.

} USB_NODE_CONNECTION_INFORMATION_EX, *PUSB_NODE_CONNECTION_INFORMATION_EX;

.
Documentation
[USB_NODE_CONNECTION_INFORMATION_EX] on MSDN
.

   int nBytes = Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX));

.

     USB_NODE_CONNECTION_INFORMATION_EX NodeConnection = new USB_NODE_CONNECTION_INFORMATION_EX();

.

     if (DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, ptrNodeConnection, nBytes, ptrNodeConnection, nBytes, out nBytesReturned, IntPtr.Zero))

.

       NodeConnection = (USB_NODE_CONNECTION_INFORMATION_EX)Marshal.PtrToStructure(ptrNodeConnection, typeof(USB_NODE_CONNECTION_INFORMATION_EX));

.

// To get the USB_PIPE_INFO data

.

   USB_NODE_CONNECTION_INFORMATION_EX connection = new USB_NODE_CONNECTION_INFORMATION_EX();

.

   size = Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX)) + 32 * Marshal.SizeOf(typeof(USB_PIPE_INFO)); // Assuming 32 should be enough, you can make this larger

.

   if (DeviceIoControl(hHub, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, ptr_connection, size, ptr_connection, size, out bytes_returned, IntPtr.Zero))

.

     connection = (USB_NODE_CONNECTION_INFORMATION_EX)Marshal.PtrToStructure(ptr_connection, typeof(USB_NODE_CONNECTION_INFORMATION_EX));

.

     if (bytes_returned != Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX)))

.

       int num = (bytes_returned - Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX))) / Marshal.SizeOf(typeof(USB_PIPE_INFO));

.

       USB_PIPE_INFO[] pipe_info = new USB_PIPE_INFO[num];

.

     // Set ptr to an USB_PIPE_INFO element and marshal it back

.

                       + Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX))

.

                       + j * Marshal.SizeOf(typeof(USB_PIPE_INFO)));

.

     pipe_info[j] = (USB_PIPE_INFO)Marshal.PtrToStructure(ptr_pipeinfo, typeof(USB_PIPE_INFO));

.
Summary
Used with DeviceIoControl and IOCTL_USB_GET_NODE_CONNECTION_NAME to get the Device Path of a downstream Hub
.

struct USB_NODE_CONNECTION_NAME

.

Structure USB_NODE_CONNECTION_NAME

.

typedef struct _USB_NODE_CONNECTION_NAME {

.

} USB_NODE_CONNECTION_NAME, *PUSB_NODE_CONNECTION_NAME;

.
Documentation
[USB_NODE_CONNECTION_NAME] on MSDN
.

   USB_NODE_CONNECTION_NAME NodeName = new USB_NODE_CONNECTION_NAME();

.

   if (DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_NAME, ptrNodeName, nBytes, ptrNodeName, nBytes, out nBytesReturned, IntPtr.Zero))

.

     NodeName = (USB_NODE_CONNECTION_NAME)Marshal.PtrToStructure(ptrNodeName, typeof(USB_NODE_CONNECTION_NAME));

.
Summary
Used with DeviceIoControl and IOCTL_USB_GET_NODE_INFORMATION to get connection-related information about a port on a USB Hub
.

// We need a separate struct to hold the union due to the fact that on 64-bit USB_HUB_NODE gets marshaled

.

struct USB_NODE_INFORMATION

.

   public USB_HUB_NODE NodeType;    /* hub, mi parent */

.

   public UsbNodeUnion u;

.

// Simpler version if you do not care about USB_MI_PARENT_INFORMATION

.

struct USB_NODE_INFORMATION

.

   public USB_HUB_INFORMATION HubInformation;      // Yeah, I'm assuming we'll just use the first form

.

Structure USB_NODE_INFORMATION

.

enum USB_HUB_NODE : uint

.

   UsbHub,

.

   UsbMIParent

.

struct USB_MI_PARENT_INFORMATION

.

struct UsbNodeUnion

.

   public USB_HUB_INFORMATION HubInformation;

.

   public USB_MI_PARENT_INFORMATION MiParentInformation;

.

typedef struct _USB_NODE_INFORMATION {

.

   USB_HUB_NODE  NodeType;

.

     USB_HUB_INFORMATION  HubInformation;

.

     USB_MI_PARENT_INFORMATION  MiParentInformation;

.

} USB_NODE_INFORMATION, *PUSB_NODE_INFORMATION;

.
Documentation
[USB_NODE_INFORMATION] on MSDN
.

   USB_NODE_INFORMATION NodeInfo = new USB_NODE_INFORMATION();

.

   NodeInfo.NodeType = (int)USB_HUB_NODE.UsbHub;

.

   if (DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes, out nBytesReturned, IntPtr.Zero))

.

     NodeInfo = (USB_NODE_INFORMATION)Marshal.PtrToStructure(ptrNodeInfo, typeof(USB_NODE_INFORMATION));

.
Summary
Used with DeviceIoControl and IOCTL_USB_GET_ROOT_HUB_NAME to return the "Symbolic Name" of a downstream USB Hub
.

struct USB_ROOT_HUB_NAME

.

Structure USB_ROOT_HUB_NAME

.

typedef struct _USB_ROOT_HUB_NAME {

.

} USB_ROOT_HUB_NAME, *PUSB_ROOT_HUB_NAME;

.
Documentation
[USB_ROOT_HUB_NAME] on MSDN
.

   USB_ROOT_HUB_NAME HubName = new USB_ROOT_HUB_NAME();

.

   if (DeviceIoControl(h, IOCTL_USB_GET_ROOT_HUB_NAME, ptrHubName, nBytes, ptrHubName, nBytes, out nBytesReturned, IntPtr.Zero))

.

     HubName = (USB_ROOT_HUB_NAME)Marshal.PtrToStructure(ptrHubName, typeof(USB_ROOT_HUB_NAME));

.
Summary
.

struct USB_STRING_DESCRIPTOR

.

   [MarshalAs(UnmanagedType.ByValTStr, SizeConst=MAXIMUM_USB_STRING_LENGTH)]

.

Structure USB_STRING_DESCRIPTOR

.

const int MAXIMUM_USB_STRING_LENGTH = 255;

.

const int USB_STRING_DESCRIPTOR_TYPE = 3;

.

typedef struct _USB_STRING_DESCRIPTOR {

.

} USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;

.

You don't use an IOCTL call directly with a USB_STRING_DESCRIPTOR structure. Instead you use a USB_DESCRIPTOR_REQUEST "request packet" with IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION. The USB_STRING_DESCRIPTOR structure is returned at the very end of the request packet. The whole idea of "writing off the edge" of a structure is counter to the way C#/VB.Net was designed to work, so you'll have to make sure to allocate sufficient amount of memory to handle both the "request packet" and the USB_STRING_DESCRIPTOR structure.

.
Documentation
[USB_STRING_DESCRIPTOR] on MSDN
.

   USB_DESCRIPTOR_REQUEST Request = new USB_DESCRIPTOR_REQUEST();

.

   Request.SetupPacket.wValue = (short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iManufacturer);

.

   if (DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ptrRequest, nBytes, ptrRequest, nBytes, out nBytesReturned, IntPtr.Zero))

.

     USB_STRING_DESCRIPTOR StringDesc = (USB_STRING_DESCRIPTOR)Marshal.PtrToStructure(ptrStringDesc, typeof(USB_STRING_DESCRIPTOR));

Constants

.

    public static readonly Guid GUID_DEVCLASS_USB = new Guid("{0x36fc9e60, 0xc465, 0x11cf, {0x80, 0x56, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}");

.

    public static readonly Guid GUID_DEVCLASS_WCEUSBS = new Guid("{0x25dbce51, 0x6c8f, 0x4a72, {0x8a, 0x6d, 0xb5, 0x4c, 0x2b, 0x4f, 0xc8, 0x35}}");

.

    public static readonly Guid GUID_DEVCLASS_FSFILTER_CONTINUOUSBACKUP = new Guid("{0x71aa14f8, 0x6fad, 0x4622, {0xad, 0x77, 0x92, 0xbb, 0x9d, 0x7e, 0x69, 0x47}}");

.

    public static Guid GUID_DEVINTERFACE_USB_DEVICE = new Guid("A5DCBF10-6530-11D2-901F-00C04FB951ED");

.

    public static Guid GUID_DEVINTERFACE_USB_HOST_CONTROLLER = new Guid("3ABF6F2D-71C4-462A-8A92-1E6861E6AF27");

.

    public static Guid GUID_DEVINTERFACE_USB_HUB = new Guid("F18A0E88-C30C-11D0-8815-00A0C906BED8");

.
Summary
The Globally Unique Identifier (GUID) for the "Interface" for a USB Host Controller
.
Summary
Used with DeviceIoControl and USB_HCD_DRIVERKEY_NAME to get the "Driver Key Name" of a USB Hub Controller
.
Summary
.

const int IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION = 0x220410;

.
Summary
Used with DeviceIoControl and USB_NODE_CONNECTION_DRIVERKEY_NAME to get the "Driver Key Name" from a device on a USB Hub
.

const int IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME = 0x220420;

.
Summary
Used with DeviceIoControl and USB_NODE_CONNECTION_INFORMATION to get information from a port on a USB Hub
.

const int IOCTL_USB_GET_NODE_CONNECTION_INFORMATION = 0x22040C;

.
Summary
Used with DeviceIoControl and USB_NODE_CONNECTION_INFORMATION_EX to get information from a port on a USB Hub
.

const int IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX = 0x220448;

.
Summary
Used with DeviceIoControl and USB_NODE_CONNECTION_NAME to get the Device Path of a device on a USB Hub
.

const int IOCTL_USB_GET_NODE_CONNECTION_NAME = 0x220414;

.
Summary
Used with DeviceIoControl and USB_NODE_INFORMATION to get information about ports on a USB Hub
.

const int IOCTL_USB_GET_NODE_INFORMATION = 0x220408;

.
Summary
Used with DeviceIoControl and USB_ROOT_HUB_NAME to get the Device Path to the USB Root Hub on a USB Controller
.

const int IOCTL_USB_GET_ROOT_HUB_NAME = 0x220408;

quickusb

33: !!!!!!
34: !!!!
35: !!
36: Close
.

QuickUSB is small USB port you can implement into any hardware project of yours. It comes with an unmanaged wrapper library encapsulating many of the USB's functions. The following pages are wrapper documentation form managed perspective. You can order one at http://www.bitwisesys.com

.

Also, see the Managed wrapper class CsQuickUSB http://code.google.com/p/csquickusb/

.

QuickUsb.dll is not unicode friendly, make sure you use ANSI encodings on your pinvoke calls!

.
Summary
Bulk USB write to device
.

[DllImport("quickusb.dll", CharSet = CharSet.Ansi)]

.

static extern int QuickUsbWriteData(IntPtr Handle, byte[] outData, int length);

.

    /// Write a block to QuckUSB module

.

        int result = QuickUsbWriteData(handle, data, data.Length);

.

            LastError =  "QUSB returned 0";

.

        LastError = "USB connection not open, please open";

.

[DllImport("quickusb.dll", CharSet = CharSet.Ansi)]

.

private static extern int QuickUsbClose(IntPtr handle);

.

Declare Function QuickUsbClose Lib "quickusb.dll" (TODO) As TODO

.

int result = QuickUsbClose(handle);

.
Documentation
[QuickUsbClose] on MSDN
.
Summary
Retrieves all attached quickUsb devices
.

[DllImport("quickusb.dll", CharSet = CharSet.Ansi)]

.

private static extern int QuickUsbFindModules(StringBuilder nameList, int bufferLength);

.

This function will return a null delimited "\0" list of attached devices. For example, after executing this function with one module connected, nameList will contain "QUSB-0\0\0". If there are two devices plugged in, nameList will contain "QUSB-0\0QUSB-1\0\0".

.

[DllImport("quickusb.dll", CharSet = CharSet.Ansi)]

.

    static extern int QuickUsbOpen(out IntPtr handle, string devName);

.

Make sure devName="QUSB-0\0\0";

.

string deviceName="QUSB-0\0\0";

.

int result = QuickUsbOpen(out handle, deviceName);

.
Summary
Preforms a bulk USB read
.

DllImport("quickusb.dll", CharSet = CharSet.Ansi)]

.

static extern int QuickUsbReadData(IntPtr Handle, byte[] outData, out int length);

.

    /// Read block from QuickUSB module

.

    /// <param name="data"> Empty byte array to fill with USB data</param>

.

            int result = QuickUsbReadData(handle, readData, out len);

.

            LastError = "USB Connection is not open";

.

        LastError = "Cannot find the QuickUSB dll library. Please install QuickUsb Drivers.";

.
Summary
Writes a byte array to the USB port (512 bytes).
.

[DllImport("quickusb.dll", CharSet = CharSet.Ansi)]

.

static extern int QuickUsbWriteData(IntPtr Handle, byte[] outData, int length);

.

    /// Write a block to QuckUSB module

.

        int result = QuickUsbWriteData(handle, data, data.Length);

.

            LastError =  "QUSB returned 0";

.

        LastError = "USB connection not open, please open";

.
Namespace
quickusb
.
Description
.
Title

userenv

.
Import
credui,advapi32,gdi32,kernel32,ole32,shell32,user32,glossary,coredll,rasapi32,mpr,netapi32,uxtheme,avifil32,aygshell,winscard,crypt32,secur32,wtsapi32,shlwapi,winspool,oleacc,rapi,oleaut32,winfax,odbc32,msi,cards,powrprof,urlmon,xolehlp,comctl32,cfgmgr32,hlink,ipaqutil,quickusb,Constants,Delegates,Enums,Interfaces,Structures

Interfaces

.

      void OnStatusBar([MarshalAs(UnmanagedType.VariantBool)] bool StatusBar);

.

      Sub OnStatusBar(<MarshalAs(UnmanagedType.VariantBool)> ByVal StatusBar As Boolean)

.

              usBuildNumber,     // Build Number.

.

    void SetMenuSB(IntPtr IntPtrShared, IntPtr holemenuRes,

.

    bool StatusBar { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] set; }

.

    bool StatusBar { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] set; }

.

    Property StatusBar() As <MarshalAs(UnmanagedType.VariantBool)> Boolean

.

    bool StatusBar { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] set; }

.

    bool StatusBar { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x193)] set; }

.

    Property StatusBar() As <MarshalAs(UnmanagedType.VariantBool)> Boolean

ntdll

.

IO_STATUS_BLOCK ioStatusBlock = new IO_STATUS_BLOCK();

.

                ref ioStatusBlock,

.

[DllImport("ntdll.dll", SetLastError=true)] static extern IntPtr NtQueryInformationFile(IntPtr fileHandle, ref IO_STATUS_BLOCK IoStatusBlock, IntPtr pInfoBlock, uint length, FILE_INFORMATION_CLASS fileInformation);

.

Declare Function NtQueryInformationFile Lib "ntdll.dll" (ByVal fileHandle As IntPtr, ByRef IoStatusBlock As IO_STATUS_BLOCK, ByVal pInfoBlock As IntPtr, ByVal length As UInteger, ByVal fileInformation As FILE_INFORMATION_CLASS) As IntPtr

.

    static extern IntPtr NtQueryInformationFile(SafeFileHandle fileHandle, ref IO_STATUS_BLOCK IoStatusBlock, IntPtr pInfoBlock, uint length, FILE_INFORMATION_CLASS fileInformation);

gdi32

.

    int[] fsUsb;

.

    int[] fsUsb;

user32

.
Summary
This Windows API function can be used to request to be informed when a device (USB) is attacted or removed.
.

    public class StatusBar

.

    public StatusBar(IntPtr hWnd)

.

        hProcess = StatusBar.OpenProcess(ProcessAccessTypes.PROCESS_ALL_ACCESS, false, this.OwningPID);

.

            allocated = StatusBar.VirtualAllocEx(hProcess, IntPtr.Zero, length, (VirtualAllocExTypes.MEM_COMMIT_OR_RESERVE), AccessProtectionFlags.PAGE_READWRITE);

.

            StatusBar.SendMessage(this._handle, SB_GETTEXT, (IntPtr)index, allocated);

.

            bool success = StatusBar.ReadProcessMemory(hProcess, allocated, buffer, length, out bytesRead);

.

            StatusBar.VirtualFreeEx(hProcess, allocated, 0, VirtualAllocExTypes.MEM_RELEASE);

.

            StatusBar.CloseHandle(hProcess);

.

        StatusBar.GetWindowThreadProcessId(this._handle, out pid);

kernel32

.

    public static bool WriteUSB(IntPtr hDevice, byte[] pBuffer, uint dwBytesToWrite, ref uint lpNumberOfBytesWritten)

.

    ' if no Volume GUID passed to sub, use the one corresponding to my USB stick

.

    ' if no Volume GUID passed to sub, use the one corresponding to my USB stick

Cut off search results after 60. Please refine your search.


 
Access PInvoke.net directly from VS: