C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[76354] Re:USB 장치 통신과 관련하여 문의 드립니다. (cfgmgr32.h)
[] 815 읽음    2022-10-27 17:30
안재욱 님이 쓰신 글 :
: cfgmgr32.h 헤더 파일을 사용할려고 했더니 에러가 나서 검색해 봤습니다.
: DDK를 설치하라고 하시는 글을 봤는데요.
: DDK는 어디서 다운받고 어떻게 설치해야 하는지 궁금해서 문의 드립니다.
:
: 구글에서 cfg.h cfgmgr32.h guiddef.h 파일을 다운받아서
: include 폴더에 복사했더니 컴파일 에러가 나네요.

//---------------------------------------------------------------------------
// Description      : Do the require the next available proper device in the system at this time.
// Parameter
//  - pGuid         : ptr to GUID registered by the driver itself
//  - outNameBuf    : the generated name for this device
// Return           : return HANDLE if the open and initialization was successful, else INVLAID_HANDLE_VALUE.
//---------------------------------------------------------------------------
HANDLE __fastcall Tfmain::USB_GetDeviceLists(void)
{
    HANDLE          hHandleValue            = INVALID_HANDLE_VALUE;
    GUID            gDeviceGUID             = StringToGUID(TEXT("{36FC9E60-C465-11CF-8056-444553540000}"));
    String          sClassGUID              = "";
    String          sDeviceGUID             = "";
    GUID            gInterfaceClassGuid     = {0x36FC9E60,0xC465,0x11CF,0x80,0x56,0x44,0x45,0x53,0x54,0x00,0x00};

    DWORD           nDeviceInfoIndex        = 0;
    bool            bResultInfo             = true;
    bool            bResultInterface        = true;
    DWORD           nDeviceInterfaceIndex   = 0;
    bool            bNoMoreInterface        = false;

    HDEVINFO                        hdDeviceInfoSet;
    SP_DEVINFO_DATA                 spDeviceInfoData;
    SP_DEVICE_INTERFACE_DATA        spDeviceInterfaceData;
    SP_DEVICE_INTERFACE_DETAIL_DATA spDeviceInterfaceDetailedData;

    sClassGUID = GUIDToString(gInterfaceClassGuid);

    //
    // Open a handle to the plug and play dev node.
    // SetupDiGetClassDevs() returns a device information set that contains info on all
    // installed devices of a specified class.
    //
    hdDeviceInfoSet = SetupDiGetClassDevs(&gInterfaceClassGuid, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
    //hdDeviceInfoSet = SetupDiGetClassDevs(NULL, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE | DIGCF_ALLCLASSES);
    if (hdDeviceInfoSet != INVALID_HANDLE_VALUE)
    {
        bResultInfo             = true;
        nDeviceInfoIndex        = 0;
        spDeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);

        while(bResultInfo)
        {
            bResultInfo = SetupDiEnumDeviceInfo(hdDeviceInfoSet, nDeviceInfoIndex, &spDeviceInfoData);
            if (bResultInfo)
            {
                sDeviceGUID             = GUIDToString(spDeviceInfoData.ClassGuid);

                bResultInterface        = true;
                nDeviceInterfaceIndex   = 0;
                bNoMoreInterface        = false;

                HDEVINFO hdDeviceInterfaceSet   = SetupDiGetClassDevs(&spDeviceInfoData.ClassGuid, NULL, NULL, DIGCF_ALLCLASSES);

                spDeviceInterfaceData.cbSize     = sizeof(hdDeviceInterfaceSet);

                while(bResultInterface)
                {
                    bResultInterface = SetupDiEnumDeviceInterfaces(hdDeviceInterfaceSet, NULL, &spDeviceInterfaceData.InterfaceClassGuid, nDeviceInterfaceIndex, &spDeviceInterfaceData);
                    if (bResultInterface)
                    {
                        GuidListsCombo->Items->Add(sDeviceGUID);
                    }
                    else
                    {
                        if (GetLastError() == ERROR_NO_MORE_ITEMS)
                        {
                            bNoMoreInterface = true;
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }

                    nDeviceInterfaceIndex++;
                }
            }

            nDeviceInfoIndex++;
        }
    }

    SetupDiDestroyDeviceInfoList(hdDeviceInfoSet);

    return hHandleValue;
}

위와 같이 코딩했는데요.
SetupDiEnumDeviceInterfaces()에서 응답이 무조건 false이고 에러값이 항상 ERROR_NO_MORE_ITEMS 이네요.
뭐가 문제일까요?
C++ Builder 6.0이고 window10입니다.
실행파일과 컴파일러 모두 관리자 권한을 주었습니다.

+ -

관련 글 리스트
76353 USB 장치 통신과 관련하여 문의 드립니다. (cfgmgr32.h) 안재욱 669 2022/10/27
76354     Re:USB 장치 통신과 관련하여 문의 드립니다. (cfgmgr32.h) 815 2022/10/27
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.