Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
178 views
in Technique[技术] by (71.8m points)

windows - Get information about disk drives result on windows7 - 32 bit system

When i run the below code on windows XP - 32 , i get the below result.

i have plugged only one usb pen drive

On Windows XP - 32 Bit
-----------------------

Drive C:
    ProductId: ST3160215AS
    ProductRevision: 3.AAD
    DeviceType: 7, DeviceNumber: 0, PartitionNumber: 1
    DevicePath: \?ide#diskst3160215as_____________________________3.aad___#5&2
7db0ed4&0&0.0.0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
    Class: DiskDrive
    Hardware ID: IDEDiskST3160215AS_____________________________3.AAD___
    Friendly Name: ST3160215AS
    Physical Device Object Name: DeviceIdeIdeDeviceP2T0L0-5
    Device Description: Disk drive
    Parent Device Instance ID: PCIIDEIDECHANNEL4&1C1E8A11&0&0
    Parent of Parent Device Instance ID: PCIVEN_8086&DEV_27C0&SUBSYS_72671462&R
EV_013&11583659&0&FA
    DeviceInstanceId: IDEDISKST3160215AS_____________________________3.AAD___5
&27DB0ED4&0&0.0.0
Drive D:
    ProductId: ST3160215AS
    ProductRevision: 3.AAD
    DeviceType: 7, DeviceNumber: 0, PartitionNumber: 2
    DevicePath: \?ide#diskst3160215as_____________________________3.aad___#5&2
7db0ed4&0&0.0.0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
    Class: DiskDrive
    Hardware ID: IDEDiskST3160215AS_____________________________3.AAD___
    Friendly Name: ST3160215AS
    Physical Device Object Name: DeviceIdeIdeDeviceP2T0L0-5
    Device Description: Disk drive
    Parent Device Instance ID: PCIIDEIDECHANNEL4&1C1E8A11&0&0
    Parent of Parent Device Instance ID: PCIVEN_8086&DEV_27C0&SUBSYS_72671462&R
EV_013&11583659&0&FA
    DeviceInstanceId: IDEDISKST3160215AS_____________________________3.AAD___5
&27DB0ED4&0&0.0.0
Drive E:
    ProductId: ST3160215AS
    ProductRevision: 3.AAD
    DeviceType: 7, DeviceNumber: 0, PartitionNumber: 3
    DevicePath: \?ide#diskst3160215as_____________________________3.aad___#5&2
7db0ed4&0&0.0.0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
    Class: DiskDrive
    Hardware ID: IDEDiskST3160215AS_____________________________3.AAD___
    Friendly Name: ST3160215AS
    Physical Device Object Name: DeviceIdeIdeDeviceP2T0L0-5
    Device Description: Disk drive
    Parent Device Instance ID: PCIIDEIDECHANNEL4&1C1E8A11&0&0
    Parent of Parent Device Instance ID: PCIVEN_8086&DEV_27C0&SUBSYS_72671462&R
EV_013&11583659&0&FA
    DeviceInstanceId: IDEDISKST3160215AS_____________________________3.AAD___5
&27DB0ED4&0&0.0.0
Drive F:
    ProductId: ST3160215AS
    ProductRevision: 3.AAD
    DeviceType: 7, DeviceNumber: 0, PartitionNumber: 4
    DevicePath: \?ide#diskst3160215as_____________________________3.aad___#5&2
7db0ed4&0&0.0.0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
    Class: DiskDrive
    Hardware ID: IDEDiskST3160215AS_____________________________3.AAD___
    Friendly Name: ST3160215AS
    Physical Device Object Name: DeviceIdeIdeDeviceP2T0L0-5
    Device Description: Disk drive
    Parent Device Instance ID: PCIIDEIDECHANNEL4&1C1E8A11&0&0
    Parent of Parent Device Instance ID: PCIVEN_8086&DEV_27C0&SUBSYS_72671462&R
EV_013&11583659&0&FA
    DeviceInstanceId: IDEDISKST3160215AS_____________________________3.AAD___5
&27DB0ED4&0&0.0.0
Drive G:
    VendorId: JetFlash
    ProductId: Transcend 2GB
    ProductRevision: 8.07
    DeviceType: 7, DeviceNumber: 1, PartitionNumber: 1
    DevicePath: \?usbstor#disk&ven_jetflash&prod_transcend_2gb&rev_8.07#e3o29u
13&0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
    Class: DiskDrive
    Hardware ID: USBSTORDiskJetFlashTranscend_2GB___8.07
    Friendly Name: JetFlash Transcend 2GB USB Device
    Physical Device Object Name: Device0000080
    Device Description: Disk drive
    Parent Device Instance ID: USBVID_058F&PID_6387E3O29U13
    Parent of Parent Device Instance ID: USBROOT_HUB204&2B6971CE&0
    DeviceInstanceId: USBSTORDISK&VEN_JETFLASH&PROD_TRANSCEND_2GB&REV_8.07E3O2
9U13&0
    Drive G: is removeable
Drive X:

When i run the below code on windows7 - 32 , i get the below result

i have plugged the same usb pen drive which is used on windows xp - 32 bit...

On Windows 7 - 32 Bit
-----------------------

Drive C:
    ProductId: Hitachi HDS721616PLA380
    ProductRevision: P22OAB3A
    DeviceType: 7, DeviceNumber: 0, PartitionNumber: 2
    DevicePath: \?ide#diskhitachi_hds721616pla380_________________p22oab3a#5&4
be38f&0&0.0.0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
    Class: DiskDrive
    Hardware ID: USBSTORDiskJetFlashTranscend_2GB___8.07
    Friendly Name: JetFlash Transcend 2GB USB Device
    Physical Device Object Name: Device000006f
    Device Description: Disk drive
    Parent Device Instance ID: USBVID_058F&PID_6387E3O29U13
    Parent of Parent Device Instance ID: USBROOT_HUB204&4E31217&0
    DeviceInstanceId: USBSTORDISK&VEN_JETFLASH&PROD_TRANSCEND_2GB&REV_8.07E3O2
9U13&0
    Drive C: is removeable
Drive D:
    ProductId: Hitachi HDS721616PLA380
    ProductRevision: P22OAB3A
    DeviceType: 7, DeviceNumber: 0, PartitionNumber: 3
    DevicePath: \?ide#diskhitachi_hds721616pla380_________________p22oab3a#5&4
be38f&0&0.0.0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
    Class: DiskDrive
    Hardware ID: USBSTORDiskJetFlashTranscend_2GB___8.07
    Friendly Name: JetFlash Transcend 2GB USB Device
    Physical Device Object Name: Device000006f
    Device Description: Disk drive
    Parent Device Instance ID: USBVID_058F&PID_6387E3O29U13
    Parent of Parent Device Instance ID: USBROOT_HUB204&4E31217&0
    DeviceInstanceId: USBSTORDISK&VEN_JETFLASH&PROD_TRANSCEND_2GB&REV_8.07E3O2
9U13&0
    Drive D: is removeable
Drive E:
    ProductId: Hitachi HDS721616PLA380
    ProductRevision: P22OAB3A
    DeviceType: 7, DeviceNumber: 0, PartitionNumber: 4
    DevicePath: \?ide#diskhitachi_hds721616pla380_________________p22oab3a#5&4
be38f&0&0.0.0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
    Class: DiskDrive
    Hardware ID: USBSTORDiskJetFlashTranscend_2GB___8.07
    Friendly Name: JetFlash Transcend 2GB USB Device
    Physical Device Object Name: Device000006f
    Device Description: Disk drive
    Parent Device Instance ID: USBVID_058F&PID_6387E3O29U13
    Parent of Parent Device Instance ID: USBROOT_HUB204&4E31217&0
    DeviceInstanceId: USBSTORDISK&VEN_JETFLASH&PROD_TRANSCEND_2GB&REV_8.07E3O2
9U13&0
    Drive E: is removeable
Drive F:
    ProductId: Hitachi HDS721616PLA380
    ProductRevision: P22OAB3A
    DeviceType: 7, DeviceNumber: 0, PartitionNumber: 5
    DevicePath: \?ide#diskhitachi_hds721616pla380_________________p22oab3a#5&4
be38f&0&0.0.0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
    Class: DiskDrive
    Hardware ID: USBSTORDiskJetFlashTranscend_2GB___8.07
    Friendly Name: JetFlash Transcend 2GB USB Device
    Physical Device Object Name: Device000006f
    Device Description: Disk drive
    Parent Device Instance ID: USBVID_058F&PID_6387E3O29U13
    Parent of Parent Device Instance ID: USBROOT_HUB204&4E31217&0
    DeviceInstanceId: USBSTORDISK&VEN_JETFLASH&PROD_TRANSCEND_2GB&REV_8.07E3O2
9U13&0
    Drive F: is removeable
Drive G:
    VendorId: JetFlash
    ProductId: Transcend 2GB
    ProductRevision: 8.07
    DeviceType: 7, DeviceNumber: 1, PartitionNumber: 1
    DevicePath: \?usbstor#disk&ven_jetflash&prod_transcend_2gb&rev_8.07#e3o29u
13&0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
    Class: DiskDrive
    Hardware ID: IDEDiskHitachi_HDS721616PLA380_________________P22OAB3A
    Friendly Name: Hitachi HDS721616PLA380 ATA Device
    Physical Device Object Name: DeviceIdeIdeDeviceP1T0L0-1
    Device Description: Disk drive
    Parent Device Instance ID: PCIIDEIDECHANNEL4&35CD87E&0&0
    Parent of Parent Device Instance ID: PCIVEN_8086&DEV_27C0&SUBSYS_27C08086&R
EV_013&2411E6FE&1&FA
    DeviceInstanceId: IDEDISKHITACHI_HDS721616PLA380_________________P22OAB3A5
&4BE38F&0&0.0.0
    Drive G: is removeable
Drive Z:

Blockquote

---------------------------------------------------------------------------------

Kindly look at the both the results...

I have plugged a same usb device on both the systems ( xp and windows7 ) but the results varies...

please check the Drive G: results on the both the Os...

Drive G: ( On Windows 7 - 32 bit )
-----------------------------------

VendorId: JetFlash
    ProductId: Transcend 2GB
    ProductRevision: 8.07
    DeviceType: 7, DeviceNumber: 1, PartitionNumber: 1
    DevicePath: \?usbstor#disk&ven_jetflash&prod_transcend_2gb&rev_8.07#e3o29u
13&0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
    Class: DiskDrive
    Hardware ID: IDEDiskHitachi_HDS721616PLA380_________________P22OAB3A
    Friendly Name: Hitachi HDS721616PLA380 ATA Device
    Physical Device Object Name: DeviceIdeIdeDeviceP1T0L0-1
    Device Description: Disk drive
    Parent Device Instance ID: PCIIDEIDECHANNEL4&35CD87E&0&0
    Parent of Parent Device Instance ID: PCIVEN_8086&DEV_27C0&SUBSYS_27C08086&R
EV_013&2411E6FE&1&FA
    DeviceInstanceId: IDEDISKHITACHI_HDS721616PLA380_________________P22OAB3A5
&4BE38F&0&0.0.0
    Drive G: is removeable

Drive G: ( On Windows XP - 32 bit )
-----------------------------------
VendorId: JetFlash
    ProductId: Transcend 2GB
    ProductRevision: 8.07
    DeviceType: 7, DeviceNumber: 1, PartitionNumber: 1
    DevicePath: \?usbstor#disk&ven_jetflash&prod_transcend_2gb&rev_8.07#e3o29u
13&0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
    Class: DiskDrive
    Hardware ID: USBSTORDiskJetFlashTranscend_2GB___8.07
    Friendly Name: JetFlash Transcend 2GB USB Device
    Physical Device Object Name: Device0000080
    Device Description: Disk drive
    Parent Device Instance ID: USBVID_058F&PID_6387E3O29U13
    Parent of Parent Device Instance ID: USBROOT_HUB204&2B6971CE&0
    DeviceInstanceId: USBSTORDISK&VEN_JETFLASH&PROD_TRANSCEND_2GB&REV_8.07E3O2
9U13&0
    Drive G: is removeable

Thank you for any help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I wrote a program in C which demonstrate how to receive the information which you need

#include <windows.h>
#include <devguid.h>    // for GUID_DEVCLASS_CDROM etc
#include <setupapi.h>
#include <cfgmgr32.h>   // for MAX_DEVICE_ID_LEN, CM_Get_Parent and CM_Get_Device_ID
#include <tchar.h>
#include <stdio.h>

#define ARRAY_SIZE(arr)     (sizeof(arr)/sizeof(arr[0]))

#pragma comment (lib, "setupapi.lib")

//
// Define the various device characteristics flags (defined in wdm.h)
//
#define FILE_REMOVABLE_MEDIA                    0x00000001
#define FILE_READ_ONLY_DEVICE                   0x00000002
#define FILE_FLOPPY_DISKETTE                    0x00000004
#define FILE_WRITE_ONCE_MEDIA                   0x00000008
#define FILE_REMOTE_DEVICE                      0x00000010
#define FILE_DEVICE_IS_MOUNTED                  0x00000020
#define FILE_VIRTUAL_VOLUME                     0x00000040
#define FILE_AUTOGENERATED_DEVICE_NAME          0x00000080
#define FILE_DEVICE_SECURE_OPEN                 0x00000100
#define FILE_CHARACTERISTIC_PNP_DEVICE          0x00000800
#define FILE_CHARACTERISTIC_TS_DEVICE           0x00001000
#define FILE_CHARACTERISTIC_WEBDAV_DEVICE       0x00002000

#pragma warning (disable: 4201)
typedef struct _IO_STATUS_BLOCK {
    union {
        NTSTATUS Status;
        PVOID Pointer;
    } DUMMYUNIONNAME;

    ULONG_PTR Information;
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
#pragma warning (default: 4201)

typedef enum _FSINFOCLASS {
    FileFsVolumeInformation       = 1,
    FileFsLabelInformation,      // 2
    FileFsSizeInformation,       // 3
    FileFsDeviceInformation,     // 4
    FileFsAttributeInformation,  // 5
    FileFsControlInformation,    // 6
    FileFsFullSizeInformation,   // 7
    FileFsObjectIdInformation,   // 8
    FileFsDriverPathInformation, // 9
    FileFsVolumeFlagsInformation,// 10
    FileFsMaximumInformation
} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;

typedef struct _FILE_FS_DEVICE_INFORMATION {
    DEVICE_TYPE DeviceType;
    ULONG Characteristics;
} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;

typedef NTSTATUS (NTAPI *LPFN_NT_QUERY_VOLUME_INFORMATION_FILE) (HANDLE FileHandle,
                                                                 PIO_STATUS_BLOCK IoStatusBlock,
                                                                 PVOID FsInformation, ULONG Length,
                                                                 FS_INFORMATION_CLASS FsInformationClass);

BOOL GetDriveTypeAndCharacteristics (HANDLE hDevice, DEVICE_TYPE *pDeviceType, ULONG *pCharacteristics)
{
    HMODULE hNtDll;
    LPFN_NT_QUERY_VOLUME_INFORMATION_FILE lpfnNtQueryVolumeInformationFile;
    NTSTATUS ntStatus;
    IO_STATUS_BLOCK IoStatusBlock;
    FILE_FS_DEVICE_INFORMATION FileFsDeviceInfo;
    BOOL bSuccess = FALSE;

    hNtDll = GetModuleHandle (TEXT("ntdll.dll"));
    if (hNtDll == NULL)
        return FALSE;

    lpfnNtQueryVolumeInformationFile = (LPFN_NT_QUERY_VOLUME_INFORMATION_FILE)GetProcAddress (hNtDll, "NtQueryVolumeInformationFile");
    if (lpfnNtQueryVolumeInformationFile == NULL)
        return FALSE;

    ntStatus = lpfnNtQueryVolumeInformationFile (hDevice, &IoStatusBlock,
                                                 &FileFsDeviceInfo, sizeof(FileFsDeviceInfo),
                                                 FileFsDeviceInformation);
    if (ntStatus == NO_ERROR) {
        bSuccess = TRUE;
        *pDeviceType = FileFsDeviceInfo.DeviceType;
        *pCharacteristics = FileFsDeviceInfo.Characteristics;
    }

    return bSuccess;
}

void FildVolumeName (LPCTSTR pszDeviceName)
{
    TCHAR szVolumeName[MAX_PATH] = TEXT("");
    TCHAR szDeviceName[MAX_PATH] = TEXT("");
    HANDLE hFind = INVALID_HANDLE_VALUE;
    DWORD dwCharCount;
    BOOL bSuccess;

    hFind = FindFirstVolume (szVolumeName, ARRAYSIZE(szVolumeName));
    if (hFind == INVALID_HANDLE_VALUE) return;

    while(TRUE) {
        //  Skip the \? prefix and remove the trailing backslash.
        size_t Index = lstrlen(szVolumeName) - 1;
        if (szVolumeName[0]     != TEXT('\') ||
            szVolumeName[1]     != TEXT('\') ||
            szVolumeName[2]     != TEXT('?')  ||
            szVolumeName[3]     != TEXT('\') ||
            szVolumeName[Index] != TEXT('\')) return; // error

        //  QueryDosDeviceW doesn't allow a trailing backslash,
        //  so temporarily remove it.
        szVolumeName[Index] = TEXT('');
        dwCharCount = QueryDosDevice (&szVolumeName[4], szDeviceName, ARRAYSIZE(szDeviceName));
        szVolumeName[Index] = TEXT('\');
        if (dwCharCount == 0) return; // error

        if (lstrcmp (pszDeviceName, szDeviceName) == 0) {
            _tprintf (TEXT("    Volume Device Name: %s
"), szVolumeName);
            return;
        }

        bSuccess = FindNextVolume (hFind, szVolumeName, ARRAYSIZE(szVolumeName));
        if (!bSuccess) {
            DWORD dwErrorCode = GetLastError();
            if (dwErrorCode == ERROR_NO_MORE_ITEMS)
                break;
            else 
                break;  // ERROR!!!
        }
    }
}

void DumpVidPidMi (LPCTSTR pszDeviceInstanceId)
{
    TCHAR szDeviceInstanceId[MAX_DEVICE_ID_LEN];
    const static LPCTSTR arPrefix[3] = {TEXT("VID_"), TEXT("PID_"), TEXT("MI_")};
    LPTSTR pszToken, pszNextToken;
    int j;

    lstrcpy (szDeviceInstanceId, pszDeviceInstanceId);

    pszToken = _tcstok_s (szDeviceInstanceId , TEXT("\#&"), &pszNextToken);
    while(pszToken != NULL) {
        for (j = 0; j < 3; j++) {
            if (_tcsncmp(pszToken, arPrefix[j], lstrlen(arPrefix[j])) == 0) {
                switch(j) {
                    case 0:
                        _tprintf (TEXT("        vid: "%s"
"), pszToken + lstrlen(arPrefix[j]));
                        break;
                    case 1:
                        _tprintf (TEXT("        pid: "%s"
"), pszToken + lstrlen(arPrefix[j]));
                        break;
                    case 2:
                        _tprintf (TEXT("        mi: "%s"
"), pszToken + lstrlen(arPrefix[j]));
                        break;
                    default:
                        break;
                }
            }
        }
        pszToken = _tcstok_s (NULL, TEXT("\#&"), &pszNextToken);
    }
}

BOOL FindDiInfos (LPCGUID pGuidInferface, LPCGUID pGuidClass, LPCTSTR pszEnumerator,
                  DEVICE_TYPE DeviceType, DWORD DeviceNumber,
                  DWORD dwDeviceInstanceIdSize,     // MAX_DEVICE_ID_LEN
                  OUT LPTSTR pszDeviceInstanceId,
                  OUT PDWORD pdwRemovalPolicy)
//#define CM_REMOVAL_POLICY_EXPECT_NO_REMOVAL             1
//#define CM_REMOVAL_POLICY_EXPECT_ORDERLY_REMOVAL        2
//#define CM_REMOVAL_POLICY_EXPECT_SURPRISE_REMOVAL       3
{
    HDEVINFO hIntDevInfo = NULL;
    DWORD dwIndex;
    BOOL bFound = FALSE; 
    HANDLE hDev = INVALID_HANDLE_VALUE;
    PSP_DEVICE_INTERFACE_DETAIL_DATA pInterfaceDetailData = NULL;

    // set defaults
    *pdwRemovalPolicy = 0;
    pszDeviceInstanceId[0] = TEXT('');

    __try {
        hIntDevInfo = SetupDiGetClassDevs (pGuidInferface, pszEnumerator, NULL,
                                           pGuidInferface != NULL? DIGCF_PRESENT | DIGCF_DEVICEINTERFACE:
                                                                   DIGCF_ALLCLASSES | DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
        if (hIntDevInfo == INVALID_HANDLE_VALUE)
            __leave;

        for (dwIndex = 0; ;dwIndex ++) {
            SP_DEVICE_INTERFACE_DATA interfaceData;
            SP_DEVINFO_DATA deviceInfoData;
            DWORD dwDataType, dwRequiredSize;
            BOOL bSuccess;

            ZeroMemory (&interfaceData, sizeof(interfaceData));
            interfaceData.cbSize = sizeof(interfaceData);
            bSuccess = SetupDiEnumDeviceInterfaces (hIntDevInfo, NULL, pGuidInferface, dwIndex, &interfaceData);
            if (!bSuccess) {
                DWORD dwErrorCode = GetLastError();
                if (dwErrorCode == ERROR_NO_MORE_ITEMS)
                    break;
                else 
                    break;  // ERROR!!!
            }

            dwRequiredSize = 0;
            bSuccess = SetupDiGetDeviceInterfaceDetail (hIntDevInfo, &interfaceData, NULL, 0, &dwRequiredSize, NULL);
            if ((!bSuccess && GetLastError() != ERROR_INSUFFICIENT_BUFFER) || dwRequiredSize == 0)
                continue;  // ERROR!!!

            if (pInterfaceDetailData)
                pInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA) LocalFree (pInterfaceDetailData);

            pInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA) LocalAlloc (LPTR, dwRequiredSize);
            pInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
            ZeroMemory (&deviceInfoData, sizeof(deviceInfoData));
            deviceInfoData.cbSize = sizeof(deviceInfoData);
            bSuccess = SetupDiGetDeviceInterfaceDetail (hIntDevInfo, &interfaceData,
                                                        pInterfaceDetailData, dwRequiredSize, &dwRequiredSize, &deviceInfoData);
            if (!bSuccess)
                continue;

            hDev = CreateFile (pInterfaceDetailData->DevicePath, 
                               0,                                   // no access to the drive
                               FILE_SHARE_READ | FILE_SHARE_WRITE,  // share mode
                               NULL,                                // default security attributes
                               OPEN_EXISTING,                       // disposition
                               0,                                   // file attributes
                               NULL);                               // do not copy file attributes
            if (hDev != INVALID_HANDLE_VALUE) {
                STORAGE_DEVICE_NUMBER sdn;
                DWORD cbBytesReturned;
                bSuccess = DeviceIoControl (hDev,                           // device to be queried
                                            IOCTL_STORAGE_GET_DEVICE_NUMBER, 
                                            NULL, 0,                        // no input buffer
                                            (LPVOID)&sdn, sizeof(sdn),      // output buffer
                                            &cbBytesReturned,               // # bytes returned
                                            (LPOVERLAPPED) NULL);           // synchronous I/O
                if (bSuccess) {
                    if (sdn.DeviceType == DeviceType &&
                        sdn.DeviceNumber == DeviceNumber) {

                        DEVINST dnDevInstParent, dnDevInstParentParent;
                        CONFIGRET ret;
                        // device found !!!
                        TCHAR szBuffer[4096];

                        _tprintf (TEXT("    DevicePath: %s
"), pInterfaceDetailData->DevicePath);

                        bSuccess = SetupDiGetDeviceInstanceId (hIntDevInfo, &deviceInfoData, pszDeviceInstanceId,
                                                               dwDeviceInstanceIdSize, &dwRequiredSize);
                        if (dwRequiredSize > MAX_DEVICE_ID_LEN)
                            continue;

                        bSuccess = SetupDiGetDeviceRegistryProperty (hIntDevInfo, &deviceInfoData, SPDRP_REMOVAL_POLICY, &dwDataType,
                                                                     (PBYTE)pdwRemovalPolicy, sizeof(DWORD), &dwRequiredSize);
                        // SPDRP_CHARACTERISTICS - Device characteristics
                        //   

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...