Click here to Skip to main content
15,915,163 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionDialog box visibility Pin
Will-O28-Oct-09 5:18
Will-O28-Oct-09 5:18 
QuestionRe: Dialog box visibility Pin
David Crow28-Oct-09 5:29
David Crow28-Oct-09 5:29 
AnswerRe: Dialog box visibility Pin
Will-O28-Oct-09 6:36
Will-O28-Oct-09 6:36 
QuestionRe: Dialog box visibility Pin
David Crow28-Oct-09 7:19
David Crow28-Oct-09 7:19 
AnswerRe: Dialog box visibility Pin
loyal ginger28-Oct-09 8:43
loyal ginger28-Oct-09 8:43 
AnswerRe: Dialog box visibility Pin
«_Superman_»28-Oct-09 9:19
professional«_Superman_»28-Oct-09 9:19 
AnswerRe: Dialog box visibility Pin
Iain Clarke, Warrior Programmer28-Oct-09 22:57
Iain Clarke, Warrior Programmer28-Oct-09 22:57 
QuestionWinUSB and SetupAPI from Visual Basic Studio 2008 Pin
Arerbac28-Oct-09 4:48
Arerbac28-Oct-09 4:48 
Hi All,
I really need help on working with USB. I cant find the answer anywhere
and I am starting to get really frustrated.

My problem is that I am trying to get a handler for a USB device so
that I can read/write to it. I was already able to compile my project using
Visual Basic 2008.

I followed these instructions to get Visual Studio 2008 to compile using winUSB libraries.:
1. Get Windows DDK.
2. Copy the following header files from DDK directory to your project

POPSHACK.H
PSHPACK1.H
SETUPAPI.H
usb100.h
usb200.h
usb.h
winusb.h
winusbio.h

3. Get Visual Basic to use those header files and pertinent libraries by:

1. Project > YOURAPP Properties --> C/C++ > General > Additional Include Directories : PROJECT_DIRECTORY
2. Linker > General > Additional Library Directories : WINDDK_DIRECTORY\lib\wxp\i386


So now everything compiles perfectly. But when I run my code, setupapi is not returning me the Interface Data.
I know the device is physically plugged in.
I know the GUID ID is valid because is written in the INF File which installs winUSB.
I verified that Windows Registry knows the device is there, and also verified the GUID is the same.
I verified Device manager sees the device with WinUSB driver and it is not showing any problems.

This is the code I am using. I took it from the How to Use WinUSB document
written by microsoft. I marked where the Interface is still empty.

<br />
BOOL CUSBDevice::GetDevicePath(LPGUID InterfaceGuid, PCHAR DevicePath, size_t BufLen)<br />
{<br />
  BOOL bResult = FALSE;<br />
  HDEVINFO deviceInfoSet;<br />
  SP_DEVINFO_DATA deviceInfoData;<br />
  SP_DEVICE_INTERFACE_DATA deviceInterfaceData;<br />
  PSP_DEVICE_INTERFACE_DETAIL_DATA detailData = NULL;<br />
  ULONG length;<br />
  ULONG requiredLength=0;<br />
  HRESULT hr;<br />
<br />
// All device infor for specific GUID<br />
  deviceInfoSet = SetupDiGetClassDevs(InterfaceGuid,         //<----- deviceInfoSet HAS A VALUE after this.<br />
                     NULL, NULL,<br />
                     DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);<br />
//Error handling code omitted.<br />
  if (deviceInfoSet == INVALID_HANDLE_VALUE){<br />
	  return bResult;<br />
  }<br />
<br />
// [2]<br />
  deviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);<br />
<br />
 bResult = SetupDiEnumDeviceInfo(deviceInfoSet,            <br />
	NULL, InterfaceGuid, 0, &deviceInterfaceData);   //<----- Im pretty sure this is where the problem lies.   <br />
<br />
  <br />
//Error handling code omitted.<br />
  if (bResult == FALSE){      //<--- I check if the function was successfull (and it wasnt)<br />
	  DWORD tError;<br />
	  tError = GetLastError();   //<--- The error value is 0x103 - End of list, meaning nothing was returned.<br />
	  <br />
	  <br />
	  return FALSE;<br />
  }<br />
<br />
// [3]<br />
  SetupDiGetDeviceInterfaceDetail(deviceInfoSet,<br />
                                  &deviceInterfaceData,<br />
                                  NULL, 0,<br />
                                  &requiredLength,<br />
                                  NULL);<br />
<br />
  detailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)<br />
     LocalAlloc(LMEM_FIXED, requiredLength);<br />
<br />
  if(NULL == detailData)<br />
  {<br />
    SetupDiDestroyDeviceInfoList(deviceInfoSet);<br />
    return FALSE;<br />
  }<br />
<br />
.... // INCOMPLETE CODE<br />
<br />
<br />
<br />


Thank you everyone, I really appreciate all the help i can get.
Dan

USB.... ITS EAAASY! Riiiiiiight....
AnswerRe: WinUSB and SetupAPI from Visual Basic Studio 2008 Pin
David Crow28-Oct-09 5:37
David Crow28-Oct-09 5:37 
GeneralRe: WinUSB and SetupAPI from Visual Basic Studio 2008 Pin
Arerbac28-Oct-09 16:37
Arerbac28-Oct-09 16:37 
QuestionRe: WinUSB and SetupAPI from Visual Basic Studio 2008 Pin
David Crow29-Oct-09 2:35
David Crow29-Oct-09 2:35 
QuestionMaximum length of MS Access Query Pin
pandit8428-Oct-09 4:35
pandit8428-Oct-09 4:35 
AnswerRe: Maximum length of MS Access Query Pin
jeron128-Oct-09 6:02
jeron128-Oct-09 6:02 
QuestionTab order while using property sheet Pin
patup928-Oct-09 4:17
patup928-Oct-09 4:17 
AnswerRe: Tab order while using property sheet Pin
transoft28-Oct-09 7:14
transoft28-Oct-09 7:14 
QuestionUsing a C++ dll in C++ project and a C# project... C# requires __stdcall c++ does not... is there a way the dll can determine who is using him? Pin
Greg Mort28-Oct-09 4:02
Greg Mort28-Oct-09 4:02 
QuestionRe: Using a C++ dll in C++ project and a C# project... C# requires __stdcall c++ does not... is there a way the dll can determine who is using him? Pin
CPallini28-Oct-09 4:13
mveCPallini28-Oct-09 4:13 
AnswerRe: Using a C++ dll in C++ project and a C# project... C# requires __stdcall c++ does not... is there a way the dll can determine who is using him? Pin
Greg Mort28-Oct-09 4:15
Greg Mort28-Oct-09 4:15 
GeneralRe: Using a C++ dll in C++ project and a C# project... C# requires __stdcall c++ does not... is there a way the dll can determine who is using him? Pin
CPallini28-Oct-09 4:21
mveCPallini28-Oct-09 4:21 
GeneralRe: Using a C++ dll in C++ project and a C# project... C# requires __stdcall c++ does not... is there a way the dll can determine who is using him? Pin
Greg Mort28-Oct-09 4:28
Greg Mort28-Oct-09 4:28 
GeneralRe: Using a C++ dll in C++ project and a C# project... C# requires __stdcall c++ does not... is there a way the dll can determine who is using him? Pin
CPallini28-Oct-09 10:11
mveCPallini28-Oct-09 10:11 
GeneralRe: Using a C++ dll in C++ project and a C# project... C# requires __stdcall c++ does not... is there a way the dll can determine who is using him? Pin
Greg Mort28-Oct-09 10:17
Greg Mort28-Oct-09 10:17 
GeneralRe: Using a C++ dll in C++ project and a C# project... C# requires __stdcall c++ does not... is there a way the dll can determine who is using him? Pin
CPallini28-Oct-09 10:19
mveCPallini28-Oct-09 10:19 
GeneralRe: Using a C++ dll in C++ project and a C# project... C# requires __stdcall c++ does not... is there a way the dll can determine who is using him? Pin
Greg Mort28-Oct-09 10:22
Greg Mort28-Oct-09 10:22 
GeneralRe: Using a C++ dll in C++ project and a C# project... C# requires __stdcall c++ does not... is there a way the dll can determine who is using him? Pin
CPallini28-Oct-09 10:27
mveCPallini28-Oct-09 10:27 

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.