Click here to Skip to main content
15,877,573 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Coonected USB Device Pin
Xing Chen14-Apr-09 21:34
Xing Chen14-Apr-09 21:34 
AnswerRe: Coonected USB Device Pin
Hamid_RT14-Apr-09 20:22
Hamid_RT14-Apr-09 20:22 
AnswerRe: Coonected USB Device Pin
Randor 14-Apr-09 23:12
professional Randor 14-Apr-09 23:12 
AnswerRe: Coonected USB Device Pin
Jonathan Davies15-Apr-09 1:22
Jonathan Davies15-Apr-09 1:22 
GeneralRe: Coonected USB Device Pin
Davitor15-Apr-09 1:40
Davitor15-Apr-09 1:40 
GeneralRe: Coonected USB Device Pin
Jonathan Davies15-Apr-09 1:53
Jonathan Davies15-Apr-09 1:53 
GeneralRe: Coonected USB Device Pin
Davitor15-Apr-09 2:04
Davitor15-Apr-09 2:04 
GeneralRe: Coonected USB Device Pin
Jonathan Davies15-Apr-09 2:53
Jonathan Davies15-Apr-09 2:53 
OK, the classes depend on WTL, but I just tried some code an MFC dialog and started getting names of devices. I put this in OnInitDialog to test it as the first wizard generated comment shows. Try it. You'll need to #include devguid.h; and then put a break point on nMemberIndex++; and look at the name in szFriendlyName. After the first name go round the loop looking at the names.

// TODO: Add extra initialization here
const GUID Guid = GUID_DEVCLASS_PORTS;
DWORD Flags = DIGCF_PRESENT |  DIGCF_DEVICEINTERFACE;
HDEVINFO hDevInfo = SetupDiGetClassDevs(&Guid, 0, 0, Flags);


BOOL bDevInfo;
int nMemberIndex = 0;
do{
    SP_DEVINFO_DATA spDevInfoData;
    spDevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
    bDevInfo = ::SetupDiEnumDeviceInfo(hDevInfo, nMemberIndex, &spDevInfoData);

    DWORD Property = SPDRP_FRIENDLYNAME;
    wchar_t  szFriendlyName[1024] = {0};
    BOOL bGotRegProp = ::SetupDiGetDeviceRegistryProperty(hDevInfo, &spDevInfoData,
                                                      Property,
                                                      0L,
                                                      (PBYTE)szFriendlyName,
                                                      2048,
                                                      0);

    nMemberIndex++;
}
while(bDevInfo);

Once you have this working then change GUID_DEVCLASS_PORTS for something that finds your device, but start with it as it is then were running the same code.
QuestionGIF showing problem Pin
subhabasu14-Apr-09 18:49
subhabasu14-Apr-09 18:49 
AnswerRe: GIF showing problem Pin
Xing Chen14-Apr-09 20:02
Xing Chen14-Apr-09 20:02 
GeneralRe: GIF showing problem Pin
subhabasu14-Apr-09 20:13
subhabasu14-Apr-09 20:13 
GeneralRe: GIF showing problem Pin
Hamid_RT14-Apr-09 20:26
Hamid_RT14-Apr-09 20:26 
GeneralRe: GIF showing problem Pin
ThatsAlok14-Apr-09 23:14
ThatsAlok14-Apr-09 23:14 
GeneralRe: GIF showing problem Pin
subhabasu14-Apr-09 20:28
subhabasu14-Apr-09 20:28 
GeneralRe: GIF showing problem Pin
Hamid_RT14-Apr-09 20:37
Hamid_RT14-Apr-09 20:37 
GeneralRe: GIF showing problem Pin
subhabasu14-Apr-09 20:51
subhabasu14-Apr-09 20:51 
GeneralRe: GIF showing problem Pin
Hamid_RT14-Apr-09 21:04
Hamid_RT14-Apr-09 21:04 
GeneralRe: GIF showing problem Pin
subhabasu14-Apr-09 22:17
subhabasu14-Apr-09 22:17 
GeneralRe: GIF showing problem Pin
Xing Chen14-Apr-09 21:48
Xing Chen14-Apr-09 21:48 
GeneralRe: GIF showing problem Pin
subhabasu14-Apr-09 23:49
subhabasu14-Apr-09 23:49 
GeneralRe: GIF showing problem Pin
Xing Chen15-Apr-09 0:22
Xing Chen15-Apr-09 0:22 
Questionversion change Pin
Purish Dwivedi14-Apr-09 18:28
Purish Dwivedi14-Apr-09 18:28 
AnswerRe: version change Pin
_AnsHUMAN_ 14-Apr-09 18:48
_AnsHUMAN_ 14-Apr-09 18:48 
QuestionRe: version change Pin
Purish Dwivedi14-Apr-09 19:25
Purish Dwivedi14-Apr-09 19:25 
AnswerRe: version change Pin
_AnsHUMAN_ 14-Apr-09 19:34
_AnsHUMAN_ 14-Apr-09 19:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.