Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Translate VB or C++ to VFP
Message
De
05/09/2014 15:26:14
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Translate VB or C++ to VFP
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01607096
Message ID:
01607096
Vues:
79
I got an USB cash drawer and the sample code with VB and C++
is there anyone familiar with VB or C++ and translate the code to VFP?

This is the code I use to open the COM cash drawer:
	thisform.Olecontrol3.portOpen=.t.
	thisform.Olecontrol3.settings='9600,n,8,1'
	thisform.Olecontrol3.output=CHR(7)
	thisform.Olecontrol3.portOpen=.f.
but now it comes the new USB cash drawer, the model is Posiflex CR4005II/CR2005/CR6005 Series

the code for VB is:
Public Declare Function DrawerOpen _
    Lib "usbcr.dll" _
    (ByVal ID As Long) _
As Long

Public Declare Function DrawerState _
    Lib "usbcr.dll" _
    (ByVal ID As Long) _
As Long

Public Declare Function OpenUSBcr _
    Lib "usbcr.dll" _
    () _
As Long

Public Declare Function CloseUSBcr _
    Lib "usbcr.dll" _
    () _
As Long

Public Declare Function RetrieveStatistics _
    Lib "usbcr.dll" _
    (ByVal ID As Long, ByVal idx As Long, _
        ByRef buf As Any, ByVal size As Long) _
As Long
the code for C++ is:
#include <stdio.h>
#include <time.h>

#include "windows.h"

int __cdecl main(int argc, char* argv[])
{
HMODULE hm;
long (*ou)();
long (*cu)();
long (*wp)(long);
long (*ps)(long);

	SetLastError( 0);
	hm = LoadLibrary( "usbcr.dll");
	printf( " hm = %p, %lu \n",hm,GetLastError());
	if ( hm==NULL ) return 1;

	SetLastError( 0);
	ou = (long(*)()) GetProcAddress( hm,"OpenUSBcr");
	printf( " ou = %p, %lu \n",ou,GetLastError());

	SetLastError( 0);
	cu = (long(*)()) GetProcAddress( hm,"CloseUSBcr");
	printf( " cu = %p, %lu \n",cu,GetLastError());

	SetLastError( 0);
	wp = (long(*)(long)) GetProcAddress( hm,"DrawerOpen");
	printf( " wp = %p, %lu \n",wp,GetLastError());

	SetLastError( 0);
	ps = (long(*)(long)) GetProcAddress( hm,"DrawerState");
	printf( " ps = %p, %lu \n",ps,GetLastError());

	printf( " OpenUSBcr = %ld \n", ou());
	for (long i=0;i<8;++i) // test 8 drawers
		{
		printf( " st1(%ld) = %ld \n", i,ps(i));
		printf( " ocr(%ld) = %ld \n", i,wp(i));
		printf( " st2(%ld) = %ld \n", i,ps(i));
		}
	printf( " CloseUSBcr = %ld \n", cu());
	
	FreeLibrary( hm);
	return 0;
}
Thanks for the help

Jerry
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform