C# c中windows Ce 6.0上的usb序列号#

C# c中windows Ce 6.0上的usb序列号#,c#,windows-ce,usbserial,C#,Windows Ce,Usbserial,我需要获取连接到windows ce 6.0设备的U盘的序列号。我尝试了KernelIoControl,得到了window ce 6.0设备的序列号,但没有连接到它的usb private static string GetDeviceID() { // Initialize the output buffer to the size of a // Win32 DEVICE_ID structure. byte[] outb

我需要获取连接到windows ce 6.0设备的U盘的序列号。我尝试了
KernelIoControl
,得到了window ce 6.0设备的序列号,但没有连接到它的usb

    private static string GetDeviceID()
    {
        // Initialize the output buffer to the size of a  
        // Win32 DEVICE_ID structure. 
        byte[] outbuff = new byte[20];
        Int32 dwOutBytes;
        bool done = false;

        Int32 nBuffSize = outbuff.Length;

        // Set DEVICEID.dwSize to size of buffer.  Some platforms look at 
        // this field rather than the nOutBufSize param of KernelIoControl 
        // when determining if the buffer is large enough.
        BitConverter.GetBytes(nBuffSize).CopyTo(outbuff, 0);
        dwOutBytes = 0;

        // Loop until the device ID is retrieved or an error occurs. 
        while (!done)
        {
            if (KernelIoControl(IOCTL_HAL_GET_DEVICEID, IntPtr.Zero,
                0, outbuff, nBuffSize, ref dwOutBytes))
            {
                done = true;
            }
            else
            {
                int error = Marshal.GetLastWin32Error();
                switch (error)
                {
                    case ERROR_NOT_SUPPORTED:
                        throw new NotSupportedException(
                            "IOCTL_HAL_GET_DEVICEID is not supported on this device",
                            new Win32Exception(error));

                    case ERROR_INSUFFICIENT_BUFFER:

                        // The buffer is not big enough for the data.  The 
                        // required size is in the first 4 bytes of the output 
                        // buffer (DEVICE_ID.dwSize).
                        nBuffSize = BitConverter.ToInt32(outbuff, 0);
                        outbuff = new byte[nBuffSize];

                        // Set DEVICEID.dwSize to size of buffer.  Some 
                        // platforms look at this field rather than the 
                        // nOutBufSize param of KernelIoControl when 
                        // determining if the buffer is large enough.
                        BitConverter.GetBytes(nBuffSize).CopyTo(outbuff, 0);
                        break;

                    default:
                        throw new Win32Exception(error, "Unexpected error");
                }
            }
        }

当我将U盘连接到windows ce 6设备时,它会显示一个新的硬盘。我需要了解已注册的新设备的属性,控制windows ce 6设备上可用的usb端口。

您可能正在寻找的是。在大窗口中,可以使用SetupDiGetDeviceProperty获取此信息,但在CE中,此值仅对驱动程序可用。我不认为有一种通用的方法可以从CE中的驱动程序那里获取这些信息。不过,您的驱动程序可能包含一个特殊的IOCTL以获取该信息。请与OEM联系。

USB设备没有序列号。您可以获得FAT32卷的序列号,但它的修改非常简单,无法用作许可证验证。买一个加密狗。那么dektop pc呢?如何从连接到电脑的usb获取序列号?我怎样才能选择我想要的。获取连接的usb的列表,并可以在其中进行选择。在c#中。如果你知道的话,你会救我的。正如我所说,在大窗口(台式电脑)中,你可以使用SetupDiGetDeviceProperty。有关示例,请参见: