ALGUEM SABE???
Olá pessoal tudo bem!!! alguém de vc's sabem converter umas linha de código em C++ para Visual basic??
Se souberem posso enviar o código!!!
Grato!!
Se souberem posso enviar o código!!!
Grato!!
Post o código akÃ, que quem souber, poderá te ajudar.
Código Read_Setup (1º primeiro módulo)
#include <cstdlib>
#include <iostream>
#include <windows.h>
typedef HANDLE (__stdcall Tfgbus_open_serial)(int port);
typedef void (__stdcall Tfgbus_close_serial)(HANDLE hnd);
typedef bool (__stdcall Tfgbus_read_setup)(HANDLE hnd, int addr);
typedef int (__stdcall Tfgbus_get_model)();
typedef int (__stdcall Tfgbus_param_count)();
typedef int (__stdcall Tfgbus_param_valint)(int index);
typedef bool (__stdcall Tfgbus_send_func)(HANDLE hnd, int display, int addr, int func, int data);
typedef bool (__stdcall Tfgbus_mt512r17_invstatus)(HANDLE hnd, int display, int addr);
typedef int (__stdcall Tfgbus_last_error)();
typedef Tfgbus_open_serial *TPfgbus_open_serial;
typedef Tfgbus_close_serial *TPfgbus_close_serial;
typedef Tfgbus_read_setup *TPfgbus_read_setup;
typedef Tfgbus_get_model *TPfgbus_get_model;
typedef Tfgbus_param_count *TPfgbus_param_count;
typedef Tfgbus_param_valint *TPfgbus_param_valint;
typedef Tfgbus_send_func *TPfgbus_send_func;
typedef Tfgbus_mt512r17_invstatus *TPfgbus_mt512r17_invstatus;
typedef Tfgbus_last_error *TPfgbus_last_error;
// Function Pointers
TPfgbus_open_serial fgbus_open_serial;
TPfgbus_close_serial fgbus_close_serial;
TPfgbus_read_setup fgbus_read_setup;
TPfgbus_get_model fgbus_get_model;
TPfgbus_param_count fgbus_param_count;
TPfgbus_param_valint fgbus_param_valint;
TPfgbus_send_func fgbus_send_func8;
TPfgbus_send_func fgbus_send_func16;
TPfgbus_mt512r17_invstatus fgbus_mt512r17_invstatus;
TPfgbus_last_error fgbus_last_error;
HINSTANCE hDll;
HANDLE hSerial;
using namespace std;
int main(int argc, char *argv[])
{
int iParamCount;
// Load dll and the functions
hDll = LoadLibrary("fgbusdrv.dll");
fgbus_open_serial = (TPfgbus_open_serial) GetProcAddress(hDll, "fgbus_open_serial");
fgbus_close_serial = (TPfgbus_close_serial) GetProcAddress(hDll, "fgbus_close_serial");
fgbus_read_setup = (TPfgbus_read_setup) GetProcAddress(hDll, "fgbus_read_setup");
fgbus_get_model = (TPfgbus_get_model) GetProcAddress(hDll, "fgbus_get_model");
fgbus_param_count = (TPfgbus_param_count) GetProcAddress(hDll, "fgbus_param_count");
fgbus_param_valint = (TPfgbus_param_valint) GetProcAddress(hDll, "fgbus_param_valint");
fgbus_send_func8 = (TPfgbus_send_func) GetProcAddress(hDll, "fgbus_send_func8");
fgbus_send_func16 = (TPfgbus_send_func) GetProcAddress(hDll, "fgbus_send_func16");
fgbus_last_error = (TPfgbus_last_error) GetProcAddress(hDll, "fgbus_last_error");
fgbus_mt512r17_invstatus = (TPfgbus_mt512r17_invstatus) GetProcAddress(hDll, "fgbus_mt512r17_invstatus");
// Open COM1
hSerial = fgbus_open_serial(2);
if (hSerial == INVALID_HANDLE_VALUE)
{
printf("Error %d
", fgbus_last_error());
system("PAUSE");
exit(0);
}
// Read instrument setup from address 8
if (!fgbus_read_setup(hSerial, 8))
{
printf("Error %d
", fgbus_last_error());
system("PAUSE");
exit(0);
}
// Get instrument model
printf("Model: %d
", fgbus_get_model());
// Get parameters count
iParamCount = fgbus_param_count();
// List the parameters values
for (int i=0; i < iParamCount; i++)
printf("Parameter %d: %d
", i, fgbus_param_valint(i));
// Close COM1
fgbus_close_serial(hSerial);
system("PAUSE");
return EXIT_SUCCESS;
}
Send_Func (2º Módulo)
#include <cstdlib>
#include <iostream>
#include <windows.h>
typedef HANDLE (__stdcall Tfgbus_open_serial)(int port);
typedef void (__stdcall Tfgbus_close_serial)(HANDLE hnd);
typedef bool (__stdcall Tfgbus_read_setup)(HANDLE hnd, int addr);
typedef int (__stdcall Tfgbus_get_model)();
typedef int (__stdcall Tfgbus_param_count)();
typedef int (__stdcall Tfgbus_param_valint)(int index);
typedef bool (__stdcall Tfgbus_send_func)(HANDLE hnd, int display, int addr, int func, int data);
typedef bool (__stdcall Tfgbus_mt512r17_invstatus)(HANDLE hnd, int display, int addr);
typedef int (__stdcall Tfgbus_last_error)();
typedef Tfgbus_open_serial *TPfgbus_open_serial;
typedef Tfgbus_close_serial *TPfgbus_close_serial;
typedef Tfgbus_read_setup *TPfgbus_read_setup;
typedef Tfgbus_get_model *TPfgbus_get_model;
typedef Tfgbus_param_count *TPfgbus_param_count;
typedef Tfgbus_param_valint *TPfgbus_param_valint;
typedef Tfgbus_send_func *TPfgbus_send_func;
typedef Tfgbus_mt512r17_invstatus *TPfgbus_mt512r17_invstatus;
typedef Tfgbus_last_error *TPfgbus_last_error;
// Function Pointers
TPfgbus_open_serial fgbus_open_serial;
TPfgbus_close_serial fgbus_close_serial;
TPfgbus_read_setup fgbus_read_setup;
TPfgbus_get_model fgbus_get_model;
TPfgbus_param_count fgbus_param_count;
TPfgbus_param_valint fgbus_param_valint;
TPfgbus_send_func fgbus_send_func8;
TPfgbus_send_func fgbus_send_func16;
TPfgbus_mt512r17_invstatus fgbus_mt512r17_invstatus;
TPfgbus_last_error fgbus_last_error;
HINSTANCE hDll;
HANDLE hSerial;
using namespace std;
int main(int argc, char *argv[])
{
// Load dll and the functions
hDll = LoadLibrary("fgbusdrv.dll");
fgbus_open_serial = (TPfgbus_open_serial) GetProcAddress(hDll, "fgbus_open_serial");
fgbus_close_serial = (TPfgbus_close_serial) GetProcAddress(hDll, "fgbus_close_serial");
fgbus_read_setup = (TPfgbus_read_setup) GetProcAddress(hDll, "fgbus_read_setup");
fgbus_get_model = (TPfgbus_get_model) GetProcAddress(hDll, "fgbus_get_model");
fgbus_param_count = (TPfgbus_param_count) GetProcAddress(hDll, "fgbus_param_count");
fgbus_param_valint = (TPfgbus_param_valint) GetProcAddress(hDll, "fgbus_param_valint");
fgbus_send_func8 = (TPfgbus_send_func) GetProcAddress(hDll, "fgbus_send_func8");
fgbus_send_func16 = (TPfgbus_send_func) GetProcAddress(hDll, "fgbus_send_func16");
fgbus_last_error = (TPfgbus_last_error) GetProcAddress(hDll, "fgbus_last_error");
fgbus_mt512r17_invstatus = (TPfgbus_mt512r17_invstatus) GetProcAddress(hDll, "fgbus_mt512r17_invstatus");
// Open COM1
hSerial = fgbus_open_serial(2);
if (hSerial == INVALID_HANDLE_VALUE)
{
printf("Error %d
", fgbus_last_error());
system("PAUSE");
exit(0);
}
printf("Sending function...
");
// Send function to address 8
if (!fgbus_send_func8(hSerial, 0, 8, 1, 10))
{
printf("Error %d
", fgbus_last_error());
system("PAUSE");
exit(0);
}
// Read instrument setup from address 8
if (!fgbus_read_setup(hSerial, 8))
{
printf("Error %d
", fgbus_last_error());
system("PAUSE");
exit(0);
}
printf("Parameter %d: %d
", 13, fgbus_param_valint(13));
// Close COM1
fgbus_close_serial(hSerial);
system("PAUSE");
return EXIT_SUCCESS;
}
#include <cstdlib>
#include <iostream>
#include <windows.h>
typedef HANDLE (__stdcall Tfgbus_open_serial)(int port);
typedef void (__stdcall Tfgbus_close_serial)(HANDLE hnd);
typedef bool (__stdcall Tfgbus_read_setup)(HANDLE hnd, int addr);
typedef int (__stdcall Tfgbus_get_model)();
typedef int (__stdcall Tfgbus_param_count)();
typedef int (__stdcall Tfgbus_param_valint)(int index);
typedef bool (__stdcall Tfgbus_send_func)(HANDLE hnd, int display, int addr, int func, int data);
typedef bool (__stdcall Tfgbus_mt512r17_invstatus)(HANDLE hnd, int display, int addr);
typedef int (__stdcall Tfgbus_last_error)();
typedef Tfgbus_open_serial *TPfgbus_open_serial;
typedef Tfgbus_close_serial *TPfgbus_close_serial;
typedef Tfgbus_read_setup *TPfgbus_read_setup;
typedef Tfgbus_get_model *TPfgbus_get_model;
typedef Tfgbus_param_count *TPfgbus_param_count;
typedef Tfgbus_param_valint *TPfgbus_param_valint;
typedef Tfgbus_send_func *TPfgbus_send_func;
typedef Tfgbus_mt512r17_invstatus *TPfgbus_mt512r17_invstatus;
typedef Tfgbus_last_error *TPfgbus_last_error;
// Function Pointers
TPfgbus_open_serial fgbus_open_serial;
TPfgbus_close_serial fgbus_close_serial;
TPfgbus_read_setup fgbus_read_setup;
TPfgbus_get_model fgbus_get_model;
TPfgbus_param_count fgbus_param_count;
TPfgbus_param_valint fgbus_param_valint;
TPfgbus_send_func fgbus_send_func8;
TPfgbus_send_func fgbus_send_func16;
TPfgbus_mt512r17_invstatus fgbus_mt512r17_invstatus;
TPfgbus_last_error fgbus_last_error;
HINSTANCE hDll;
HANDLE hSerial;
using namespace std;
int main(int argc, char *argv[])
{
int iParamCount;
// Load dll and the functions
hDll = LoadLibrary("fgbusdrv.dll");
fgbus_open_serial = (TPfgbus_open_serial) GetProcAddress(hDll, "fgbus_open_serial");
fgbus_close_serial = (TPfgbus_close_serial) GetProcAddress(hDll, "fgbus_close_serial");
fgbus_read_setup = (TPfgbus_read_setup) GetProcAddress(hDll, "fgbus_read_setup");
fgbus_get_model = (TPfgbus_get_model) GetProcAddress(hDll, "fgbus_get_model");
fgbus_param_count = (TPfgbus_param_count) GetProcAddress(hDll, "fgbus_param_count");
fgbus_param_valint = (TPfgbus_param_valint) GetProcAddress(hDll, "fgbus_param_valint");
fgbus_send_func8 = (TPfgbus_send_func) GetProcAddress(hDll, "fgbus_send_func8");
fgbus_send_func16 = (TPfgbus_send_func) GetProcAddress(hDll, "fgbus_send_func16");
fgbus_last_error = (TPfgbus_last_error) GetProcAddress(hDll, "fgbus_last_error");
fgbus_mt512r17_invstatus = (TPfgbus_mt512r17_invstatus) GetProcAddress(hDll, "fgbus_mt512r17_invstatus");
// Open COM1
hSerial = fgbus_open_serial(2);
if (hSerial == INVALID_HANDLE_VALUE)
{
printf("Error %d
", fgbus_last_error());
system("PAUSE");
exit(0);
}
// Read instrument setup from address 8
if (!fgbus_read_setup(hSerial, 8))
{
printf("Error %d
", fgbus_last_error());
system("PAUSE");
exit(0);
}
// Get instrument model
printf("Model: %d
", fgbus_get_model());
// Get parameters count
iParamCount = fgbus_param_count();
// List the parameters values
for (int i=0; i < iParamCount; i++)
printf("Parameter %d: %d
", i, fgbus_param_valint(i));
// Close COM1
fgbus_close_serial(hSerial);
system("PAUSE");
return EXIT_SUCCESS;
}
Send_Func (2º Módulo)
#include <cstdlib>
#include <iostream>
#include <windows.h>
typedef HANDLE (__stdcall Tfgbus_open_serial)(int port);
typedef void (__stdcall Tfgbus_close_serial)(HANDLE hnd);
typedef bool (__stdcall Tfgbus_read_setup)(HANDLE hnd, int addr);
typedef int (__stdcall Tfgbus_get_model)();
typedef int (__stdcall Tfgbus_param_count)();
typedef int (__stdcall Tfgbus_param_valint)(int index);
typedef bool (__stdcall Tfgbus_send_func)(HANDLE hnd, int display, int addr, int func, int data);
typedef bool (__stdcall Tfgbus_mt512r17_invstatus)(HANDLE hnd, int display, int addr);
typedef int (__stdcall Tfgbus_last_error)();
typedef Tfgbus_open_serial *TPfgbus_open_serial;
typedef Tfgbus_close_serial *TPfgbus_close_serial;
typedef Tfgbus_read_setup *TPfgbus_read_setup;
typedef Tfgbus_get_model *TPfgbus_get_model;
typedef Tfgbus_param_count *TPfgbus_param_count;
typedef Tfgbus_param_valint *TPfgbus_param_valint;
typedef Tfgbus_send_func *TPfgbus_send_func;
typedef Tfgbus_mt512r17_invstatus *TPfgbus_mt512r17_invstatus;
typedef Tfgbus_last_error *TPfgbus_last_error;
// Function Pointers
TPfgbus_open_serial fgbus_open_serial;
TPfgbus_close_serial fgbus_close_serial;
TPfgbus_read_setup fgbus_read_setup;
TPfgbus_get_model fgbus_get_model;
TPfgbus_param_count fgbus_param_count;
TPfgbus_param_valint fgbus_param_valint;
TPfgbus_send_func fgbus_send_func8;
TPfgbus_send_func fgbus_send_func16;
TPfgbus_mt512r17_invstatus fgbus_mt512r17_invstatus;
TPfgbus_last_error fgbus_last_error;
HINSTANCE hDll;
HANDLE hSerial;
using namespace std;
int main(int argc, char *argv[])
{
// Load dll and the functions
hDll = LoadLibrary("fgbusdrv.dll");
fgbus_open_serial = (TPfgbus_open_serial) GetProcAddress(hDll, "fgbus_open_serial");
fgbus_close_serial = (TPfgbus_close_serial) GetProcAddress(hDll, "fgbus_close_serial");
fgbus_read_setup = (TPfgbus_read_setup) GetProcAddress(hDll, "fgbus_read_setup");
fgbus_get_model = (TPfgbus_get_model) GetProcAddress(hDll, "fgbus_get_model");
fgbus_param_count = (TPfgbus_param_count) GetProcAddress(hDll, "fgbus_param_count");
fgbus_param_valint = (TPfgbus_param_valint) GetProcAddress(hDll, "fgbus_param_valint");
fgbus_send_func8 = (TPfgbus_send_func) GetProcAddress(hDll, "fgbus_send_func8");
fgbus_send_func16 = (TPfgbus_send_func) GetProcAddress(hDll, "fgbus_send_func16");
fgbus_last_error = (TPfgbus_last_error) GetProcAddress(hDll, "fgbus_last_error");
fgbus_mt512r17_invstatus = (TPfgbus_mt512r17_invstatus) GetProcAddress(hDll, "fgbus_mt512r17_invstatus");
// Open COM1
hSerial = fgbus_open_serial(2);
if (hSerial == INVALID_HANDLE_VALUE)
{
printf("Error %d
", fgbus_last_error());
system("PAUSE");
exit(0);
}
printf("Sending function...
");
// Send function to address 8
if (!fgbus_send_func8(hSerial, 0, 8, 1, 10))
{
printf("Error %d
", fgbus_last_error());
system("PAUSE");
exit(0);
}
// Read instrument setup from address 8
if (!fgbus_read_setup(hSerial, 8))
{
printf("Error %d
", fgbus_last_error());
system("PAUSE");
exit(0);
}
printf("Parameter %d: %d
", 13, fgbus_param_valint(13));
// Close COM1
fgbus_close_serial(hSerial);
system("PAUSE");
return EXIT_SUCCESS;
}
O que faz realmente tal código??
Captura temperatura e dados de termógrafos que usam conecção serial!!!
Você tem como testar esses termógrafos?
aqui no vb mania mesmo tem um código pronto que faz a leitura da serial com time,
este código abre a porta, faz a leitura e fecha a porta, dai em diante é o tratamento de paramentros, se vc observar o código ve que ele te passa alguns parametros que são diretamente impressos na tela.
http://www.vbmania.com.br/vbmdetail.php?varID=2783
aqui no vb mania mesmo tem um código pronto que faz a leitura da serial com time,
este código abre a porta, faz a leitura e fecha a porta, dai em diante é o tratamento de paramentros, se vc observar o código ve que ele te passa alguns parametros que são diretamente impressos na tela.
http://www.vbmania.com.br/vbmdetail.php?varID=2783
Cara no PlanetSourceCode vc encontra um prog que faz a conversão que vc quer.
Dê uma procurada tb no SourceForge
http://www.planet-source-code.com/
http://www.programmersheaven.com/
http://sourceforge.net/
Abs
Dê uma procurada tb no SourceForge
http://www.planet-source-code.com/
http://www.programmersheaven.com/
http://sourceforge.net/
Abs
Legal os códigos e os exemplos [S42]
(Olha, tem emoticons novos)
Mas um aviso.... Ao invez de escrever um tópico com o titulo de "help", "me ajudem!", etc... Coloque um tÃtulo que chame mais atenção
No seu caso seria "Como converto linhas de C++ para VB6?"
(Olha, tem emoticons novos)
Mas um aviso.... Ao invez de escrever um tópico com o titulo de "help", "me ajudem!", etc... Coloque um tÃtulo que chame mais atenção

No seu caso seria "Como converto linhas de C++ para VB6?"
Tópico encerrado , respostas não são mais permitidas