As I said above, the reason is because DevicePath will be WCHAR array.
As I said above, the reason is because DevicePath will be WCHAR array.
Even when i try to convert it to QString my application gets crashed.
i used like below
qDebug ()<<QString:::fromWCharArray ( pDetData->DevicePath );
Any helps
Yes, because you are still passing a NULL pointer. Read my code fragment again.
newb (31st May 2010)
hi ..
Thank you...i have corrected my code as you said.
included these codes...
SP_DEVICE_INTERFACE_DETAIL_DATA *pDetData = NULL;
DWORD dwDetDataSize = sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA) + 256;
pDetData = (SP_DEVICE_INTERFACE_DETAIL_DATA*) malloc (dwDetDataSize);
pDetData->cbSize = sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA);
now ..
qDebug ()<<QString::fromWCharArray ( pDetData->DevicePath );
the above print statement returns the below
"\\?\usb#vid_04f2&pid_0111#5&1ba5a77f&0&2#{a5dcbf1 0-6530-11d2-901f-00c04fb951ed}"
but it seems to be for usb keyboard.
i want to get the usb device which i plugged...
how can i get it..
Looking for some guidence...
Thank you
Last edited by newb; 31st May 2010 at 10:16.
then look at post #8 in this thread. Since you re-asked your question in post #9, ignoring my post, I assumed you wanted a list of USB devices, not the one that got plugged in.
sorry for the confusion..
even if it gives the list of usb devices means ..why it displays only one ( usb keyboard )...
why it doesnot display my usb modem which is plugged ...
please help me up.
Last edited by newb; 31st May 2010 at 10:34.
You'll need to step through the code and see where it exits your loop. Maybe one of the calls fail. You also seem to have some unnecessary code there, although it is difficult to read.
. . . .
Last edited by newb; 31st May 2010 at 14:39.
Hi...
the application comes and prints this
"\\?\usb#vid_04f2&pid_0111#5&1ba5a77f&0&2#{a5dcbf1 0-6530-11d2-901f-00c04fb951ed}"
again it goes to while loop ....
here it gets breaked in the else statement...
Qt Code:
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { // Change the buffer size. if (buffer) LocalFree(buffer); buffer = (LPTSTR)LocalAlloc(LPTR,buffersize); } else { qDebug ()<<"Here it quits the application"; // Insert error handling here. break; }To copy to clipboard, switch view to plain text mode
Any ideas in this....
Last edited by newb; 31st May 2010 at 11:49.
Hello Qt Experts....
Kindly guide me on my problem...
Say, did you write that code or copy it from somewhere? As you don't seem to understand how it works?
Secondly, why are you expecting the call to fail with an insufficient buffer error code? Surely having a sufficient buffer size is a good thing, rather than a bad one?
Actually i want to get the vendor id and product id of a usb device which is get plugged....
i searched for Qt related implementation but i don seem to get any sample source code .
So i searched forums and links for that..
so i referred the links and followed the code they have used ..
Any ideas
Bookmarks