C/Visual C - Traducir código de C++ a Visual Basic Net

   
Vista:

Traducir código de C++ a Visual Basic Net

Publicado por raxe (2 intervenciones) el 21/07/2010 10:07:30
Buenos días.

Tengo que conectar con un dispositivo en el Puerto COM y me han pasado este código de ejemplo en C++
Alguno que domine ambos lenguajes me lo pudiera traducir o adaptar a Visual Basic Net por favor.

Gracias,

/////////////////////////////////////////////////////////////////////////////
// connect to the PaymentManager-Dll

#define WM_PAYMENTMESSAGE (WM_USER+1)

extern "C" {
typedef int __stdcall nTypST(void);
typedef int __stdcall nTypI(HWND,int,int,int,int);
typedef int __stdcall nTypII(int,int,int,int);
static HINSTANCE vendlib = NULL;
static nTypST *openpaymentmanager = NULL;
static nTypI *startpaymentmanager = NULL;
static nTypST *stoppaymentmanager = NULL;
static nTypST *closepaymentmanager = NULL;
static nTypII *setpaymentmanager = NULL;
}

static BOOL LoadVendLib()
{
if (vendlib) return TRUE;
vendlib = LoadLibrary("PaymentManager.dll");
if (vendlib)
{
openpaymentmanager = (nTypST*) GetProcAddress(vendlib,"openpaymentmanager");
startpaymentmanager = (nTypI*) GetProcAddress(vendlib,"startpaymentmanager");
stoppaymentmanager = (nTypST*) GetProcAddress(vendlib,"stoppaymentmanager");
closepaymentmanager = (nTypST*) GetProcAddress(vendlib,"closepaymentmanager");
setpaymentmanager = (nTypII*) GetProcAddress(vendlib,"setpaymentmanager");
if (!openpaymentmanager ||
!startpaymentmanager ||
!stoppaymentmanager ||
!closepaymentmanager ||
!setpaymentmanager)
{
// Library not found
openpaymentmanager = NULL;
startpaymentmanager = NULL;
stoppaymentmanager = NULL;
closepaymentmanager = NULL;
setpaymentmanager = NULL;
vendlib = NULL;
return FALSE;
}
return TRUE;
}
else
{
return FALSE;
}
}

int PM_Open()
{
int iRtn = 0x1000; // dll not found
if (LoadVendLib()) iRtn = (*openpaymentmanager) ();
return iRtn;
}

int PM_Close()
{
if (vendlib)
return (*closepaymentmanager) ();
else
return FALSE;
}

int PM_Start(HWND hWnd, int devices, int messageConfig, int protocol)
{
if (vendlib)
return (*startpaymentmanager) (hWnd, WM_PAYMENTMESSAGE, devices, messageConfig,
protocol);
else
return -1;
}

int PM_Stop()
{
if (vendlib)
return (*stoppaymentmanager) ();
else
return -1;
}

int PM_Set(int command, int selection, int info1, int info2)
{
if (vendlib)
return (*setpaymentmanager) (command, selection, info1, info2);
else
return -1;
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder