begin process at 2012 05 29 06:29:18
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive C/C++

 > 

Archives

 > 

Au secours

 > 

ou est l'erreur?(dll)


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

ou est l'erreur?(dll)

mercredi 15 mars 2006 à 17:16:39 | ou est l'erreur?(dll)

anthonycosson

bon voila jai fais une classe en c++ .NET et je desire en faire une dll mais bon voila il   y a plein de probleme que j'ai du mal à saisir...

// dll.h

#pragma once

#include <stdio.h>

#include <stdlib.h>

#include "Windows.h"

#include "Winbase.h"

using namespace System;

namespace dll

{

public __gc class liaison

{

private:

static COMMTIMEOUTS *Timeout=new COMMTIMEOUTS(/*sizeof(COMMTIMEOUTS)*/);

//char port[5];

int parite;

int bitstop;

HANDLE h_com;

static DCB *ladcb=new DCB(/*sizeof( DCB)*/);

int i;

private:

//envoi ok//

int envoi(unsigned char* command)

{

DWORD nboce;

int retour;

retour=WriteFile(this->h_com,command,11,&nboce,NULL);

if((retour==0) || (nboce<=0))

{

return 0;

}

char* bc=(char*)malloc(100);

return this->reponse_lecteur(bc);

}

//param ok//

int param()

{

int debit;

int tab[8];

tab[0]=300;

tab[1]=600;

tab[2]=1200;

tab[3]=2400;

tab[4]=4800;

tab[5]=9600;

tab[6]=19200;

tab[7]=38400;

int tab1[9][2];

tab1[0][0]=1;

tab1[0][1]=2;

tab1[1][0]=1;

tab1[1][1]=0;

tab1[2][0]=1;

tab1[2][1]=1;

tab1[3][0]=1;

tab1[3][1]=3;

tab1[4][0]=1;

tab1[4][1]=4;

tab1[5][0]=2;

tab1[5][1]=2;

tab1[6][0]=2;

tab1[6][1]=0;

tab1[7][0]=2;

tab1[7][1]=1;

tab1[8][0]=2;

tab1[8][1]=3;

for(int i=0;i<8;i++)

{

debit=tab[i];

for(int y=0;y<9;y++)

{

parite=tab1[y][1];

bitstop=tab1[y][0];

if(!GetCommState(h_com,ladcb))

{

CloseHandle(h_com);

return 0;

}

if(debit==300)

ladcb->BaudRate=CBR_300;

if(debit==600)

ladcb->BaudRate=CBR_600;

if(debit==1200)

ladcb->BaudRate=CBR_1200;

if(debit==2400)

ladcb->BaudRate=CBR_2400;

if(debit==4800)

ladcb->BaudRate=CBR_4800;

if(debit==9600)

ladcb->BaudRate=CBR_9600;

if(debit==19200)

ladcb->BaudRate=CBR_19200;

if(debit==38400)

ladcb->BaudRate=CBR_38400;

if(parite==0)

ladcb->Parity=NOPARITY;

if(parite==2)

ladcb->Parity=EVENPARITY;

if(parite==1)

ladcb->Parity=ODDPARITY;

if(parite==3)

ladcb->Parity=MARKPARITY;

if(parite==4)

ladcb->Parity=SPACEPARITY;

if(bitstop==1)

ladcb->StopBits=ONESTOPBIT;

if(bitstop==3)

ladcb->StopBits=ONE5STOPBITS;

if(bitstop==2)

ladcb->StopBits=TWOSTOPBITS;

if(!SetCommState(h_com,ladcb))

{

CloseHandle(h_com);

return 0;

}

Timeout->ReadTotalTimeoutConstant=500;

if(!SetCommTimeouts(h_com,Timeout))

{

CloseHandle(h_com);

return 0;

}

unsigned char command[11];

command[0]=0x16;

command[1]=0x4D;

command[2]=0x0D;

command[3]=0x32;

command[4]=0x33;

command[5]=0x32;

command[6]=0x42;

command[7]=0x41;

command[8]=0x44;

command[9]=0x3F;

command[10]=0x2E;

if(this->envoi(command)!=0)

{

return 1;

}

}

}

return 0;

}

//recherche ok//

int recherche()

{

char port[5];

port[0]='C';

port[1]='O';

port[2]='M';

port[3]=(char)i;

port[4]='\0';

h_com=CreateFile(port,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);

if(h_com == INVALID_HANDLE_VALUE)

{

CloseHandle(h_com);

return 0;

}

return this->param();

}

public:

liaison(){}

//connection ok//

int connection()

{

unsigned char tab[5]={0x31,0x32,0x33,0x34};

for(i=0;i<5;i++)

{

/*port[0]='C';

port[1]='O';

port[2]='M';

port[3]=tab[i];

port[4]='\0';*/

if(this->recherche()!=0)

{

return 1;

}

else

this->deconnexion();

}

i=0;

return 0;

}

//Modifier_TimeOut ok//

int Modifier_TimeOut(int seconde)

{

Timeout->ReadTotalTimeoutConstant=(1000*seconde);

if(!SetCommTimeouts(h_com,Timeout))

{

CloseHandle(h_com);

return 0;

}

return 1;

}

//reponse_lecteur ok voir temps du sleep//

int reponse_lecteur(char* CB1)

{

Sleep(200);

DWORD nb;

if(!ReadFile(h_com,CB1,100,&nb,NULL))

return 0;

CB1[nb]='\0';

if(nb==0)

return 0;

else

return nb;

}

//volume ok

int volume(int volume)

{

unsigned char command[11];

command[0]=0x16;

command[1]=0x4D;

command[2]=0x0D;

command[3]=0x42;

command[4]=0x45;

command[5]=0x50;

command[6]=0x4C;

command[7]=0x56;

command[8]=0x4C;

if(volume==0)

command[9]=0x30;

if(volume==1)

command[9]=0x31;

if(volume==2)

command[9]=0x32;

if(volume==3)

command[9]=0x33;

command[10]=0x2E;

return this->envoi(command);

}

//trigger mode ok//

int trigger_mode(int trigger)

{

unsigned char command[11];

command[0]=0x16;

command[1]=0x4D;

command[2]=0x0D;

command[3]=0x54;

command[4]=0x52;

command[5]=0x47;

command[6]=0x4D;

command[7]=0x4F;

command[8]=0x44;

if(trigger==0)

command[9]=0x30;

if(trigger==1)

command[9]=0x31;

command[10]=0x2E;

return this->envoi(command);

}

//a voir//

int baud_rate(int rate)

{

unsigned char command[11];

command[0]=0x16;

command[1]=0x4D;

command[2]=0x0D;

command[3]=0x32;

command[4]=0x33;

command[5]=0x32;

command[6]=0x42;

command[7]=0x41;

command[8]=0x44;

if(rate==300)

command[9]=0x30;

if(rate==600)

command[9]=0x31;

if(rate==1200)

command[9]=0x32;

if(rate==2400)

command[9]=0x33;

if(rate==4800)

command[9]=0x34;

if(rate==9600)

command[9]=0x35;

if(rate==19200)

command[9]=0x36;

if(rate==38400)

command[9]=0x37;

command[10]=0x2E;

if(this->envoi(command)==0)

return 0;

if(this->param()==0)

return 0;

return 1;

}

//word_length

int word_length(int value)

{

unsigned char command[11];

command[0]=0x16;

command[1]=0x4D;

command[2]=0x0D;

command[3]=0x32;

command[4]=0x33;

command[5]=0x32;

command[6]=0x57;

command[7]=0x52;

command[8]=0x44;

if(value==1)

command[9]=0x33;

if(value==2)

command[9]=0x30;

if(value==3)

command[9]=0x36;

if(value==4)

{

command[9]=0x31;

command[10]=0x32;

}

if(value==5)

command[9]=0x39;

if(value==6)

command[9]=0x34;

if(value==7)

command[9]=0x31;

if(value==8)

command[9]=0x37;

if(value==9)

{

command[9]=0x31;

command[9]=0x33;

}

if(value==10)

{

command[9]=0x31;

command[10]=0x30;

}

if(value!=10 || value!=9 || value!=4)

command[10]=0x2E;

else

command[11]=0x2E;

if(this->envoi(command)==0)

return 0;

if(this->param()==0)

return 0;

return 1;

}

//deconnexion ok//

void deconnexion()

{

CloseHandle(h_com);

}

};

}

mercredi 15 mars 2006 à 20:57:03 | Re : ou est l'erreur?(dll)

SAKingdom

Membre Club
Nous aussi on a du mal à saisir. Si tu nous disait c'est quoi l'erreure.

___________________________________________
Les plus grands esprits trouvent toujours une solution

jeudi 16 mars 2006 à 16:09:57 | Re : ou est l'erreur?(dll)

SAKingdom

Membre Club
Que dit ton compilateur

___________________________________________
Les plus grands esprits trouvent toujours une solution

jeudi 16 mars 2006 à 16:51:46 | Re : ou est l'erreur?(dll)

anthonycosson

lecturecodebar error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@$$FYAPAXI@Z)

lecturecodebar fatal error LNK1120: 1 unresolved externals

de plus les mallocs ne sont pas accepté mais ca j'ai trouver, en faite je comprend pas c'est koi leurs problemes aux dll avec les pointeurs ou pour gérer la mémoire.


Cette discussion est classée dans : int, return, command, tab1, ladcb


Répondre à ce message

Sujets en rapport avec ce message

probleme a la creation d'une dll [ par anthonycosson ] salut a tous donc voila mon probleme, j'ai fait une classe et ensuite j'ai voulu la mettre en dll mais lorsque je compile cette erreur la s'affiche qu probleme avec une boite de dialogue [ par anonyme_man_in_this_world ] salut !! ça sera simpa si vous m'aidiez a corriger ce code ******************************************************************************* # tableau [ par imanedaoudi ] Salut,Je veux récuperer le tableaux triée sans faire return, avec ce programme je recupere le tableau non trier ,comment faire pour recuperer le tab t Help! Pb de spécif en C [ par tomalille ] Bonjour, je suis en train d'écrire un programme et je voudrai faire une fonction qui renvoit un tableau d'entier.Je n'arrive pas à faire la spécif.Vou Probleme de WNDPROC [ par threadom ] Explication Voila j'essaye tout simplement de me faire une classe pour [Performance] Passage par valeur | Passage vers pointeur [ par BIG_BOSS_001 ] Bonjour,Je me pose une petite question sur les performances entre le passage par valeur et par pointeur.Je sais que le premier reçoit par la pile une Utilisé du multithread sous unix (C++) [ par Kenshiroooo ] Bonjour, très probablement qu'il existe déja un poste dans lequel il est expliquer ce que je vais dès maintenant vous demander... mais je pers patienc problème d'ouverture de fichier [ par marc_dd ] Bonjour voila j'ai codé un peti programme avec sauvetage et ouverture de fichier, quand je sauve pas de problème il créer le fichier ou le mets à jour Problème avec CFileDialog [ par fuliculi ] Bonjour à tous,j'ai un soucis avec CFileDialog. Ce n'est pas la première fois que je l'utilise mais là je bloque complètement... Dans mon programme (M que des boucles. [ par pratix ] Salut à tous.Je post mon prg cherchenbr modifié (voir sujet précédent ''int main" ).Programme compilé avec visual C++ 06. ( zéro erreur )j'ai essay


Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,546 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales