I am testing the error and there is no error,
that is my problem
the same function work with no problem if i open my usb logitec mouse
Code:
... DeviceHandle=CreateFile(detailData->DevicePath,0,FILE_SHARE_READ | FILE_SHARE_WRITE,
&SecurityAttributes,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
DisplayLastError("CreateFile: ");
...
void CUsbhidiocDlg::DisplayLastError(const char * Operation)
{
//Display a message and the last error in the log List Box.
LPVOID lpMsgBuf;
USHORT Index = 0;
std::string strLastError = "";
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0,
NULL
);
//Display the last error.
strLastError = Operation ;
strLastError+= (LPCTSTR)lpMsgBuf;
//Trim CR/LF from the error message.
strLastError[strLastError.size()-2]=0;
_listResult.AddString(strLastError.c_str());
_listResult.SelectPos(-1);
// ScrollToBottomOfListBox(Index);
LocalFree(lpMsgBuf);
}