Coonected USB Device
-
Hi All I have a problem to get information of connected USB Device.I am useing
OnMyDeviceChange(WPARAM wParam, LPARAM lParam);
function which is provide me all information.But when USB Device is connected all ready and my application is start after connecteion of USB Device then i havn't found any information of USB Device.Can any one give me advice to how to get connected USB Device information.Plz help me
-
Hi All I have a problem to get information of connected USB Device.I am useing
OnMyDeviceChange(WPARAM wParam, LPARAM lParam);
function which is provide me all information.But when USB Device is connected all ready and my application is start after connecteion of USB Device then i havn't found any information of USB Device.Can any one give me advice to how to get connected USB Device information.Plz help me
-
Hi All I have a problem to get information of connected USB Device.I am useing
OnMyDeviceChange(WPARAM wParam, LPARAM lParam);
function which is provide me all information.But when USB Device is connected all ready and my application is start after connecteion of USB Device then i havn't found any information of USB Device.Can any one give me advice to how to get connected USB Device information.Plz help me
See http://www.beyondlogic.org/[^].
Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )
-
1.You must use
RegisterDeviceNotification()
to let system notify you application. 2.Add message handler forWM_DEVICECHANGE
.i am useing both RegisterDeviceNotification and WM_DEVICECHANGE.And i am getting information when my application is running and USB Device is connect.But When my application is not running and USB drive is connected and my application is start after connection of USB Device then information is not showing.But USb Device is still connected. So problem is that how to get information allready connection of USB Device.Plz help me
-
i am useing both RegisterDeviceNotification and WM_DEVICECHANGE.And i am getting information when my application is running and USB Device is connect.But When my application is not running and USB drive is connected and my application is start after connection of USB Device then information is not showing.But USb Device is still connected. So problem is that how to get information allready connection of USB Device.Plz help me
-
Hi All I have a problem to get information of connected USB Device.I am useing
OnMyDeviceChange(WPARAM wParam, LPARAM lParam);
function which is provide me all information.But when USB Device is connected all ready and my application is start after connecteion of USB Device then i havn't found any information of USB Device.Can any one give me advice to how to get connected USB Device information.Plz help me
Your RegisterDeviceNotification[^] code is probably working correctly, however it will only detect changes while your application is running. You failed to mention what type of USB device your application needs to enumerate. I will assume that you need all USB device types. You will essentially need to call SetupDiGetClassDevs[^] and pass the enumerator filter of "USB". Dont be frightened by the Windows Driver Kit references in the MSDN documentation. You will be able to use the SetupAPI without the DDK installed, although I believe you will need Platform SDK/Microsoft SDK. The following link should be enough to get you started: How to enumerate hardware devices by using SetupDi calls[^] You should modify the Microsoft sample code to something like the following:
#pragma comment (lib,"Setupapi.lib") hDevInfo = SetupDiGetClassDevs(NULL,"USB", 0,DIGCF_PRESENT | DIGCF_ALLCLASSES );
You can perform additional device filtering using the System-Supplied Device Setup Classes[^] or other Enumerator strings such as "USBSTOR". Best Wishes, -David Delaune -
Hi All I have a problem to get information of connected USB Device.I am useing
OnMyDeviceChange(WPARAM wParam, LPARAM lParam);
function which is provide me all information.But when USB Device is connected all ready and my application is start after connecteion of USB Device then i havn't found any information of USB Device.Can any one give me advice to how to get connected USB Device information.Plz help me
Hi, Have a look at the my article [^] which describes a class a wrote for detecting devices. The example screen shots show the detection of USB devices, amongst others. The code example
const GUID Guid = GUID_DEVCLASS_USB;
CDevInfo cDevInfo(m_hWnd, DIGCF_PRESENT , &Guid);shows how to use the class to detect just USB devices actually present.
-
Hi, Have a look at the my article [^] which describes a class a wrote for detecting devices. The example screen shots show the detection of USB devices, amongst others. The code example
const GUID Guid = GUID_DEVCLASS_USB;
CDevInfo cDevInfo(m_hWnd, DIGCF_PRESENT , &Guid);shows how to use the class to detect just USB devices actually present.
-
Getting error
al error C1083: Cannot open include file: 'atlapp.h': No such file or directory
AtlApp.h is part of WTL. The article uses WTL for the windows, dialogs, listboxes etc. I guess you're using MFC?
-
AtlApp.h is part of WTL. The article uses WTL for the windows, dialogs, listboxes etc. I guess you're using MFC?
-
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 onnMemberIndex++;
and look at the name inszFriendlyName
. 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.