Hello ,
i am write a usb application in which my application will communicate with the USB device.the problem is that i am unable to execute successfully the CreateFile() function .
i am attaching the piece of code , Can i open .sys file ir which file i have to open to acess the uSB device
#include <iostream.h>
#include <windows.h>
#include <winioctl.h>
#include <stdio.h>void main(void )
{
HANDLE htest;
char write_hex_data =0x003;
char written_hex_data =0x004;
unsigned long k=20;
int write;
//htest=CreateFile("\\\\.\\usbport.sys",GENERIC_WRITE|GENERIC_READ ,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_READONLY,NULL);
htest=CreateFile("C:\WINNT\system32\drivers\usbhub.sys",GENERIC_READ | GENERIC_WRITE ,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_READONLY,NULL);
write =GetLastError();
cout<<write <<endl;
cout<<htest<<endl;
write=WriteFile(htest,&write_hex_data,10,&k,NULL);
cout<<write<<endl;
return ;
}