473,396 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

The Usb programm

Hi Debasisdas

The following is the way i have tried
DEFINE_GUID(USBIODS_GUID,0x1f537664, 0x37a9, 0x48c1, 0x96, 0xe7, 0x1a, 0x8a, 0x18, 0x48, 0x41, 0xfd);
// {1F537664-37A9-48c1-96E7-1A8A184841FD}



HDEVINFO hInfo = SetupDiGetClassDevs((struct _GUID *)&USBIODS_GUID, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);

int i;
char *Devices[10]; // an array of cstrings
char name[150];
for ( i=0; ; ++i)
{
SP_INTERFACE_DEVICE_DATA Interface_Info;

Interface_Info.cbSize = sizeof(Interface_Info);
// Enumerate device


if (!SetupDiEnumInterfaceDevice(hInfo, NULL, (LPGUID)
&USBIODS_GUID,i, &Interface_Info))

{
SetupDiDestroyDeviceInfoList(hInfo);
return(i);
}

DWORD needed; // get the required lenght
SetupDiGetInterfaceDeviceDetail(hInfo, &Interface_Info,
NULL, 0, &needed, NULL);

PSP_INTERFACE_DEVICE_DETAIL_DATA detail = (PSP_INTERFACE_DEVICE_DETAIL_DATA) malloc(needed);
if (!detail)
{
SetupDiDestroyDeviceInfoList(hInfo);
return(i);
}

detail->cbSize =
sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
if (!SetupDiGetInterfaceDeviceDetail(hInfo,&Interface _Info,detail, needed,NULL, NULL))
{
free((PVOID) detail);
SetupDiDestroyDeviceInfoList(hInfo);
return(i);
}

strncpy(name, detail->DevicePath, sizeof(name));
free((PVOID) detail);
strcpy(Devices[i],name); // keep a copy of each device name
printf("%s", name);

}


HANDLE hUsbDevice = CreateFile(name, GENERIC_READ |GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
}

This is the way i have used, kindly suggest any changes to be done for the same as the

if (!SetupDiEnumInterfaceDevice(hInfo, NULL, (LPGUID)
&USBIODS_GUID,i, &Interface_Info))

is failing and entering the if condition in the code
Nov 20 '07 #1
3 3344
debasisdas
8,127 Expert 4TB
The code is OK but what exactly you are trying to do ?
A brief description of the problem is requested.
Nov 20 '07 #2
The code is OK but what exactly you are trying to do ?
A brief description of the problem is requested.
The purpose of this program is to establish communincation b/n the USB device. Here in the program the blocked if loop is failing and the in the debug condition im getting this result
InterfaceClassGuid {CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC} as this is failing here
and the program returns from this if loop
Nov 20 '07 #3
I hope .. i am missing some initialisation procedure for the devices,
some more info

compiler : VC6++
OS :windows xp
Nov 20 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Atz | last post by:
Hi to all ! 1.) Is there a way to make exe file from java class file ? 2.) I want to make multiple uninstalation of some files, under windows. E.g. instead of going into control panel ,...
7
by: broebel | last post by:
hey, for the real programmers amongst you, this may be really annoying but I've been learning the language for only two days. this is my problem, in this programm,which already works I now...
1
by: Toni | last post by:
How can I insert a Backgroundimage in my C++ programm? Microsoft Visual Studio C++, Win 32 Konsolenanwendung. Can you answer me in germany, because my english is very bad. An example where very...
0
by: Toni | last post by:
How can I insert a Backgroundimage in my C++ programm? Microsoft Visual Studio C++, Win 32 Konsolenanwendung. Can you answer me in germany, because my english is very bad. An example where very...
2
by: Kostadis.Spirou | last post by:
how can i make this programm with class???? #include <fstream> #include <cstdlib> #include <stdio.h> #include <stdlib.h> #include <iostream> using namespace std;
0
by: Alexander F?hrmann | last post by:
Grüß euch! Wir haben hier in der Firma ein Problem mit Access! Sobald man im Access den VBA-Editor aufrufen will, kommt folgender fehler! -------------------- Runtime Error!
6
by: TIM | last post by:
for example i have one simple programm int main() { int test = NULL; while(1){ printf("%d\n",test); getch(); test++; }
2
by: Jan | last post by:
Hello! I am looking for a way to do a search&replace in ASCII-Files by a vb.net 2005 programm. Of coarse I can open the files, loop to every line, make a replace, and save the line. But I wonder...
83
by: deppy_3 | last post by:
Hi.I am started learning Programm language C before some time.I am trying to make a programm about a very simple "sell shop".This programm hasn't got any compile problem but when i run it i face...
2
by: LordChaos | last post by:
Dear all, I am a newbie in Java, I got the following problem: I am going through a list of directories. The programm looks inside each directory for specific files and writes them in an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.