Click here to Skip to main content
14,934,046 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: playing video in VC++ Pin
alex_kenobe16-Aug-06 3:15
Memberalex_kenobe16-Aug-06 3:15 
GeneralRe: playing video in VC++ Pin
Hamid_RT16-Aug-06 4:32
MemberHamid_RT16-Aug-06 4:32 
GeneralRe: playing video in VC++ Pin
alex_kenobe17-Aug-06 2:37
Memberalex_kenobe17-Aug-06 2:37 
QuestionCommunicating w/ USB Device Pin
Sagito11-Aug-06 0:59
MemberSagito11-Aug-06 0:59 
AnswerRe: Communicating w/ USB Device Pin
Cedric Moonen11-Aug-06 1:02
MemberCedric Moonen11-Aug-06 1:02 
GeneralRe: Communicating w/ USB Device Pin
Sagito12-Aug-06 9:07
MemberSagito12-Aug-06 9:07 
AnswerRe: Communicating w/ USB Device Pin
kitty511-Aug-06 4:53
Memberkitty511-Aug-06 4:53 
GeneralRe: Communicating w/ USB Device Pin
Sagito12-Aug-06 9:10
MemberSagito12-Aug-06 9:10 
Well, my code looks like this now:

<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
	int erro = 0;<br />
<br />
	Localizar_ZP3();<br />
<br />
	cout << "A procurar abrir comunicacao com central no endereco: " << endl;<br />
	cout << Devices[1] << endl;<br />
<br />
	hUsbDevice = CreateFile(Devices[0].c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);<br />
<br />
	erro = GetLastError();<br />
	cout << endl << "Verificacao de erros no CreateFile: " << erro << endl << endl;<br />
	<br />
	/****************************** Tentar receber dados *********************************/<br />
<br />
	if (!Comunicar())<br />
		cout << "Erro ao estabelecer comunicacao..." << endl;<br />
	else<br />
		cout << "Comunicacao foi estabelecida com sucesso!" << endl;<br />
<br />
	cout << "A terminar ligacao..." << endl;<br />
	CloseHandle(hUsbDevice);<br />
<br />
	if (0 == GetLastError())<br />
		cout << "Ligacao terminada com sucesso!" << endl;<br />
	else<br />
	{<br />
		cout << "Ocorreu um erro ao terminar ligacao..." << endl;<br />
		cout << "Codigo de erro: " << GetLastError() << endl;<br />
	}<br />
<br />
	cout << endl;<br />
	system("pause");<br />
<br />
	return 0;<br />
}<br />
<br />
int Localizar_ZP3()<br />
{<br />
	cout << "A entrar no loop de pesquisa de equipamentos USB..." << endl << endl;<br />
<br />
	HDEVINFO hInfo = SetupDiGetClassDevs(&ZP3COMM_GUID, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);<br />
<br />
	int i;<br />
<br />
	for (DWORD i=0; ; ++i)<br />
	{<br />
		SP_INTERFACE_DEVICE_DATA Interface_Info;<br />
		Interface_Info.cbSize = sizeof(Interface_Info);<br />
<br />
		int erro = 0;<br />
<br />
		if (!SetupDiEnumDeviceInterfaces(hInfo, NULL, (LPGUID) &ZP3COMM_GUID,i, &Interface_Info))<br />
		{<br />
			erro = GetLastError();<br />
<br />
			if (erro == 259)<br />
				cout << "Fim dos itens a listar!" << endl;<br />
			<br />
			cout << "Numero de iteracoes: " << i << endl << endl;<br />
<br />
			SetupDiDestroyDeviceInfoList(hInfo);<br />
			return(i);<br />
		}<br />
<br />
		DWORD needed;<br />
		<br />
		SetupDiGetInterfaceDeviceDetail(hInfo, &Interface_Info, NULL, 0, &needed, NULL);<br />
		PSP_INTERFACE_DEVICE_DETAIL_DATA detail = (PSP_INTERFACE_DEVICE_DETAIL_DATA) malloc(needed);<br />
		<br />
		if (!detail)<br />
		{<br />
			SetupDiDestroyDeviceInfoList(hInfo);<br />
			return(i);<br />
		}<br />
<br />
		detail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);<br />
<br />
		if (!SetupDiGetInterfaceDeviceDetail(hInfo, &Interface_Info,detail, needed,NULL, NULL))<br />
		{<br />
			free((PVOID) detail);<br />
			SetupDiDestroyDeviceInfoList(hInfo);<br />
			return(i);<br />
		}<br />
<br />
		char name[MAX_PATH];<br />
		strncpy(name, detail->DevicePath, sizeof(name));<br />
		free((PVOID) detail);<br />
<br />
		cout << "Endereco " << i << ": " << endl;<br />
		cout << name << endl << endl;<br />
		Devices[i] = name;<br />
	}<br />
<br />
	return 0;<br />
}<br />
<br />
bool Comunicar()<br />
{<br />
	ULONG nBytes;<br />
	DWORD numLidos;<br />
	PVENDORPACKET pPacket = NULL;<br />
	char* BufferLeitura = NULL;<br />
<br />
	bool sucesso = true;<br />
<br />
	sucesso = ReadFile(hUsbDevice, BufferLeitura, 80, &numLidos, NULL); //DeviceIoControl(hUsbDevice, IOCTL_LER, NULL, 0, pPacket, 8, &nBytes, NULL);<br />
<br />
	if (sucesso)<br />
	{<br />
		cout << "A operacao de comunicacao foi bem sucedida." << endl;<br />
		cout << BufferLeitura << endl;<br />
		cout << numLidos << endl;<br />
		cout << endl;<br />
	}<br />
	else<br />
	{<br />
		cout << "Ocorreu um erro ao executar ReadFile()" << endl;<br />
		cout << "Codigo de erro: " << GetLastError() << endl;<br />
	}<br />
<br />
	return sucesso;<br />
}


Think I've got something wrong in this code?

Thanks again, I'm getting really desperate w/ this... Sigh | :sigh:
Questionclient of a class Pin
Tara1411-Aug-06 0:50
MemberTara1411-Aug-06 0:50 
AnswerRe: client of a class Pin
Steen Krogsgaard11-Aug-06 1:00
MemberSteen Krogsgaard11-Aug-06 1:00 
AnswerRe: client of a class Pin
Stephen Hewitt11-Aug-06 2:00
MemberStephen Hewitt11-Aug-06 2:00 
QuestionDoes MFC support MathML Pin
nitaryann11-Aug-06 0:08
Membernitaryann11-Aug-06 0:08 
AnswerRe: Does MFC support MathML Pin
Cedric Moonen11-Aug-06 0:14
MemberCedric Moonen11-Aug-06 0:14 
QuestionXML Parsing in Win98 Pin
anwar102610-Aug-06 23:25
Memberanwar102610-Aug-06 23:25 
AnswerRe: XML Parsing in Win98 [modified] Pin
Cedric Moonen10-Aug-06 23:31
MemberCedric Moonen10-Aug-06 23:31 
AnswerRe: XML Parsing in Win98 Pin
Hamid_RT11-Aug-06 0:16
MemberHamid_RT11-Aug-06 0:16 
GeneralRe: XML Parsing in Win98 Pin
anwar102611-Aug-06 0:46
Memberanwar102611-Aug-06 0:46 
GeneralRe: XML Parsing in Win98 Pin
kakan11-Aug-06 1:22
professionalkakan11-Aug-06 1:22 
AnswerRe: XML Parsing in Win98 Pin
Nemanja Trifunovic11-Aug-06 1:50
MemberNemanja Trifunovic11-Aug-06 1:50 
AnswerRe: XML Parsing in Win98 Pin
Zac Howland11-Aug-06 4:03
MemberZac Howland11-Aug-06 4:03 
QuestionCan we add customized toolbar to childframe? [modified] Pin
narayanagvs10-Aug-06 23:09
Membernarayanagvs10-Aug-06 23:09 
QuestionHow to read header and image pixel data from DICOM file Pin
Arul Joseph10-Aug-06 23:03
MemberArul Joseph10-Aug-06 23:03 
AnswerRe: How to read header and image pixel data from DICOM file Pin
Hamid_RT11-Aug-06 0:25
MemberHamid_RT11-Aug-06 0:25 
QuestionConvert RGB buffer to mpg or h263 buffer format Pin
huutribk200110-Aug-06 22:25
Memberhuutribk200110-Aug-06 22:25 
QuestionInstall Shield Pin
Sarath C10-Aug-06 22:12
MemberSarath C10-Aug-06 22:12 

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.