Vb6 with C dll

tatawissa Messages postés 2 Date d'inscription mardi 27 août 2013 Statut Membre Dernière intervention 28 août 2013 - 27 août 2013 à 19:14
tatawissa Messages postés 2 Date d'inscription mardi 27 août 2013 Statut Membre Dernière intervention 28 août 2013 - 28 août 2013 à 00:11
hello, Unfortunately, I have a little problem.

I programmed a C program that is functional, this program uses a dll file.

but the terms of reference requires that I work with VB6 to manipulate the functions of the dll file written in C.

Unfortunately, the code that I programmed in VB6 does not work and gives me no result.

I give you the C function code and the VB6 code not FUNCTIONAL.

the C code fonctionel:
 #define DATA_ARRAY  129
long int s;
int i,k,A1;	
char buffer[3],a[9], tmp[20];
char data[DATA_ARRAY ];
char input[DATA_ARRAY ];
char text1[] ="palette 1";

struct ANSWER {
	int iStatus;
	unsigned char idata[DATA_ARRAY ];
	int iBytes;
}ans_data;

struct INSTRUCTION {
	unsigned char iCode[DATA_ARRAY ];
	int iBytes;
}ins_data;



 short int  Evaluation_unit_quit(BOOL Mode,int ncom);
 short int  Evaluation_unit_reset(BOOL Mode,int ncom);
short int  System_memory_examine(BOOL Mode,int ncom, char* status);
 short int  Data_medium_type_adjust(BOOL Mode,int ncom, char* data_medium);
 short int  Double_sided_read_letter_active(BOOL Mode,int ncom);
 short int  Autoread_letter_terminate(BOOL Mode,int ncom);
short int  Version_message(BOOL Mode,int ncom, char* version);
int  Comset(int iPort, int iBaud, int iBits, int iStop, int iParity, int iTimeout);
 short int  Data_medium_read(BOOL Mode,int ncom, char* head, char* status, char* data);
 int  ComReset(int iPort);
 short int  Bytes_write(BOOL Mode,int ncom, char* head, char* status, char* adresse, char* number, char* data);
 short int  Byte_read(BOOL Mode,int ncom, char* head, char* status, char* adresse, char* number, char* data);
 short int  Reset(BOOL Mode,int ncom, char* head, char* status); 
 void  Check_total_compute(void);
BOOL  Send(int ncom);
 BOOL Receive(int ncom); 
void ShiftLeft(unsigned char* data, int place);
void ArrayCopy(char* dest, unsigned char* source, int place);
 int HexToInt(char* hex);
 BOOL Receive1(int ncom);

#pragma code()


printf("\t\t\t\tProgramme d'exploitation des RFID\n\n");
printf("\t\t\t\tLECTURE PALETTE 1\n\n");
Comset(1,9600,8,1,0,20);

Evaluation_unit_quit(FALSE,1);
Evaluation_unit_reset(FALSE,1);
Data_medium_type_adjust(FALSE, 1,"4");

Byte_read(TRUE,1, "2", buffer, "00", "09", data);

//printf("\nStatus: %s\t", buffer);
//printf("\n\nles données sont::\n");

	for ( i = 0; i < 10; i++) 
	{
		a[i] = data[i];
		printf("%c", a[i]);

	} //if (a=(s.c_str()));


printf("\n comparaison des chaines de caracters:  \t%s, et ,\t%s \n",a,text1);
A1= strcmp(a,text1);
printf("A 1=%d",A1);






the VB6 code no fonctional:
Option Explicit


Private Declare Function Comset Lib "RFID_VC_VB1.dll" ( _
                ByVal iPort As Long, _
                ByVal iBaud As Long, _
                ByVal iBits As Long, _
                ByVal iStop As Long, _
                ByVal iParity As Long, _
                ByVal iTimeout As Long) As Long
 
Private Declare Function ComReset Lib "RFID_VC_VB1.dll" ( _
                ByVal iPort As Long) As Long
 
Private Declare Function Evaluation_unit_quit Lib "RFID_VC_VB1.dll" ( _
                ByVal Mode As Long, _
                ByVal nCom As Long) As Long
 
Private Declare Function Evaluation_unit_reset Lib "RFID_VC_VB1.dll" ( _
                ByVal Mode As Long, _
                ByVal nCom As Long) As Long
 
Private Declare Function System_memory_examine Lib "RFID_VC_VB1.dll" ( _
                ByVal Mode As Long, _
                ByVal nCom As Long, _
                ByVal status As String) As Long
 
Private Declare Function Data_medium_type_adjust Lib "RFID_VC_VB1.dll" ( _
                ByVal Mode As Long, _
                ByVal nCom As Long, _
                ByVal data_medium As String) As Long
 
Private Declare Function Double_sided_read_letter_active Lib "RFID_VC_VB1.dll" ( _
                ByVal Mode As Long, _
                ByVal nCom As Long, _
                ByVal head As String, _
                ByVal buffer As String, _
                ByVal adresse As String, _
                ByVal number As String, _
                ByVal data As String) As Long
 
Private Declare Function Autoread_letter_terminate Lib "RFID_VC_VB1.dll" ( _
                ByVal Mode As Long, _
                ByVal nCom As Long, _
                ByVal head As String, _
                ByVal buffer As String, _
                ByVal adresse As String, _
                ByVal number As String, _
                ByVal data As String) As Long
 
Private Declare Function Version_message Lib "RFID_VC_VB1.dll" ( _
                ByVal Mode As Long, _
                ByVal nCom As Long, _
                ByVal head As String, _
                ByVal buffer As String, _
                ByVal adresse As String, _
                ByVal number As String, _
                ByVal data As String) As Long
 
Private Declare Function Bytes_write Lib "RFID_VC_VB1.dll" ( _
                ByVal Mode As Long, _
                ByVal nCom As Long, _
                ByVal head As String, _
                ByVal buffer As String, _
                ByVal adresse As String, _
                ByVal number As String, _
                ByVal data As String) As Long
 
Private Declare Function Byte_read Lib "RFID_VC_VB1.dll" ( _
                ByVal Mode As Long, _
                ByVal nCom As Long, _
                ByVal head As String, _
                ByVal status As String, _
                ByVal adresse As String, _
                ByVal number As String, _
                ByVal data As String) As Long
 
Private Declare Function Data_medium_read Lib "RFID_VC_VB1.dll" ( _
                ByVal Mode As Long, _
                ByVal nCom As Long, _
                ByVal head As String, _
                ByVal status As String, _
                ByVal data As String) As Long
 
Private Declare Function Reset Lib "RFID_VC_VB1.dll" ( _
                ByVal Mode As Long, _
                ByVal nCom As Long, _
                ByVal head As String, _
                ByVal status As String) As Long
 
Private Declare Function Send Lib "RFID_VC_VB1.dll" ( _
                ByVal nCom As Long) As Long
 
Private Declare Function Receive Lib "RFID_VC_VB1.dll" ( _
                ByVal nCom As Long) As Long
 
Private Declare Function HexToInt Lib "RFID_VC_VB1.dll" ( _
                ByVal hex As String) As Long
 
Private Declare Sub Check_total_compute Lib "RFID_VC_VB1.dll" ()
 
Private Declare Sub ArrayCopy Lib "RFID_VC_VB1.dll" ( _
        ByVal dest As String, _
        ByVal source As String, _
        ByVal place As Long)
 
Private Declare Sub ShiftLeft Lib "RFID_VC_VB1.dll" ( _
        ByVal data As String, _
        ByVal place As Long)
 
 
Const DATA_ARRAY = 129



'***************************
 
Private Type ANSWER
    iStatus As Long
    idata(DATA_ARRAY) As Byte
    iBytes As Long
End Type
 
Private Type INSTRUCTION
     iCode(DATA_ARRAY) As Byte
     iBytes As Long
End Type
 
Dim ans_data As ANSWER
Dim ins_data As INSTRUCTION
 
Sub test()
        Dim data$, source$, dest$, hex$, head$, statut$, adresse$, number$, buffer$, data_medium$
    Dim iPort&, iBaud&, iBits&, iStop&, iParity, iTimeout, Mode&, nCom&
 
End Sub

Private Sub Command1_Click()
Dim buffer As String
Data1 = "palette1"
buffer = "00"
Dim retour_Bytes_write As Long

 retour_Bytes_write = Bytes_write(True, 1, "2", buffer, "00", "16", Data1)
'Text2.Text = Data1

End Sub

Private Sub Command2_Click()

Dim i As Integer
Dim n As Integer
Dim retour_byte_read As Long
Dim Text() As Byte
Dim data(DATA_ARRAY) As Byte
Dim lettre As Byte
Dim buffer(3) As Byte
Dim a(10) As Byte

Text() = "palette1"

retour_byte_read = Str(Byte_read(0, 1, "2", buffer, "00", "09", data))
  
For i = 1 To 10
a(i) = data(i)
Next i
 n = StrComp(a, Text)
 If (n = 0) Then
 MsgBox ("ok")
 Else
 MsgBox a
    
 End If
 

End Sub

Private Sub Comreset1_Click()
Dim retour_Comreset As Long
retour_Comreset = ComReset(1)
End Sub

Private Sub Comset1_Click()

Dim retour_Comset As Long
Dim retour_quit As Long
Dim retour_reset As Long
Dim retour_adjust As Long
retour_Comset = Str(Comset(1, 9600, 8, 1, 0, 20))

retour_quit = Str(Evaluation_unit_quit(-1, 1))

retour_reset = Str(Evaluation_unit_reset(-1, 1))
  
retour_adjust = Str(Data_medium_type_adjust(-1, 1, "4"))


End Sub

2 réponses

cs_ShayW Messages postés 3253 Date d'inscription jeudi 26 novembre 2009 Statut Membre Dernière intervention 3 décembre 2019 57
Modifié par cs_ShayW le 27/08/2013 à 22:05
Hello
As the forum serves the francophone community i will answer in french.

ton code en c il n'y a seulement que les headers de chaque fonction
mais aucune n'est implémentées
ex
short int  Evaluation_unit_quit(BOOL Mode,int ncom);

et où est l'implémentation de cette fonction ?
0
tatawissa Messages postés 2 Date d'inscription mardi 27 août 2013 Statut Membre Dernière intervention 28 août 2013
28 août 2013 à 00:11
très bien moi aussi de formation francophone :)
pour les fonctions en C sont alimenté comme suit
 Comset(1,9600,8,1,0,20);

Evaluation_unit_quit(FALSE,1);
Evaluation_unit_reset(FALSE,1);
Data_medium_type_adjust(FALSE, 1,"4");

Byte_read(TRUE,1, "2", buffer, "00", "09", data);
   


déjà le code C est bien fonctionnel, mon problème qui me bloque depuis quelques jours est le fonctionnement du code VB6 dans le quel j'ai implémenté de la même façon que C mais sans résultat.
0
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 211
27 août 2013 à 22:18
Gabaté,
Sabali paté bayan da nemé !
Bolaty dana kalary da kamaré ? na sikary da fanafanany ?
bola tariva da fiana ?
0
Rejoignez-nous