probleme a la creation d'une dll
j'ai cree une classe en NET ensuite j'ai voulu en faire une dll mais la j'ai un ptit probleme ave __gc et __nogc qui est du a mes pointeur en global donc sa cree une erreur si quelquun avait une idée ?
voila le debut de mon code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
namespace lector
{
public __gc class liaison
{
private:
COMMTIMEOUTS Timeout;<=====probleme
//char port[5];
int parite;
int bitstop;
HANDLE h_com;
DCB ladcb;<=======probleme
int po;
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)po;
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();
} |
voila les erreurs:
c:\Documents and Settings\anthonycosson\Mes documents\Visual Studio Projects\lector\lector.h(88): error C2664: 'GetCommState' : cannot convert parameter 2 from 'DCB __gc *' to 'LPDCB'
c:\Documents and Settings\anthonycosson\Mes documents\Visual Studio Projects\lector\lector.h(129): error C2664: 'SetCommState' : cannot convert parameter 2 from 'DCB __gc *' to 'LPDCB'
Cannot convert a managed type to an unmanaged type
voila voila donc merci davance