Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9211603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:20:09+00:00 2026-06-18T01:20:09+00:00

I have a rather interesting problem for which I’m unable to find a resolution.

  • 0

I have a rather interesting problem for which I’m unable to find a resolution. I’m using Setup API to list drives in the system. I have no trouble using the code listed below when setting the enumerator to “IDE”. My angst comes when the enumerator value is set to “SCSI”. Code which reproduces this problem is below:

#include <iostream>
#include <Windows.h>
#include <SetupAPI.h>
#include <cfgmgr32.h>
#include <devguid.h>

int main() {
    std::cout << "Looking for only SCSI disks" << std::endl;
    HDEVINFO hDevs(SetupDiGetClassDevs(&GUID_DEVCLASS_DISKDRIVE, "SCSI", NULL, DIGCF_PRESENT));
    if(INVALID_HANDLE_VALUE == hDevs) {
        DWORD error(GetLastError());
        std::cout << "Handle returned is invalid. Error code: " << error << std::endl;
        return 1;
    }

    SP_DEVINFO_DATA sp = {sizeof(SP_DEVINFO_DATA)};
    char buff[256];
    memset(buff, 0, 256);
    DWORD index(0);

    std::cout << "The handle is valid, listing drives now" << std::endl;
    while(SetupDiEnumDeviceInfo(hDevs, index++, &sp)) {
        CM_Get_Device_ID(sp.DevInst, buff, 256, 0);
        std::cout << buff << std::endl;
        memset(buff, 0, 256);
    }

    SetupDiDestroyDeviceInfoList(hDevs);
    return 0;
}

As you can see, there is nothing remarkable about this code. The problem is, on certain laptops, this code errors at SetupDiGetClassDevs(). Checking GetLastError() reveals that it failed for ERROR_INVALID_DATA (0xd). What I don’t understand is why. This exact same program, run on my development box both as my user (with administrator rights) and as an unprivileged user, works just fine whether or not SCSI drives are present.

I know that the GUID in use is correct. It’s defined in devguid.h. “SCSI” is a valid PnP enumerator as is referenced on this MSDN page and also from examining the “Enumerator” property in the Device Manager. The third argument may be NULL and the fourth is a valid defined flag for this function. I know this because, except for these laptops, this works on all systems I’ve ever tried it on (which, in my organization, is quite a few). I’m hoping that someone here may know about what would cause SetupDiGetClassDevs() to fail for this error with these conditions, or could at least point me in the right direction. I’m not a Windows expert and I could be missing something on system configuration or permissions (although not implied from the error).

As I hope is clear, I’ve run this code on the one laptop I can test it on as both a user with Administrator privileges and as the Administrator user: both with the same result. The laptop is an HP EliteBook 8460p running Windows 7 64-bit Service Pack 1. Compiling this code in 32 or 64 bits makes no difference.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:20:10+00:00Added an answer on June 18, 2026 at 1:20 am

    I’m going to post the answer I got from a fellow on the MSDN support forums to help someone who may be confounded by this same issue. Apparently, this is expected behavior for Windows 7. If the system has never seen hardware with the enumerator specified to SetupDiGetClassDevs(), then a failure occurs and this error code is expected.

    For reference, the thread where I asked this question is linked here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather interesting problem. I use FileZilla and Notepad++ to edit my
I'm fairly new to Powershell but I've got a rather interesting problem. I have
I can't seem to find an answer to this rather interesting problem. In google
I am using ASP .NET MVC 3 and I have an interesting problem to
I have an interesting (but frustraring) problem. I have an application which uses the
Here’s my problem, I have two different lists, list a which contains the name
I have a rather interesting issue with SVG animation. I am animating along a
I have a rather large text corpus, of which I would like to check
I have a rather enormous project in which I'm trying to retrofit in-memory data.
I have a rather large SQL file which starts with the byte order marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.