Bonjour a tous,

Voila j'éssai de lire ce qui est écrit sur la console par la fonction SnmpUtilPrintAsnAny.

J''essaye d'utiliser la fonction ReadConsoleOutputCharacter, mais je n'arrive pas a la faire marcher. Le buffer est toujours egale à "".

Je join mon code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
int main(int argc, char* argv[])
{
        SnmpVarBindList snmpVarList;
        AsnInteger errorStatus,errorIndex;
        LPSNMP_MGR_SESSION session;
        char resultat[MAX_PATH];
        COORD CordDef,Cord2;
        CHAR_INFO *test;
 
        //Initialisation snmpVarList
        snmpVarList.list = NULL;
        snmpVarList.len = 1;
        snmpVarList.list = (SnmpVarBind *)realloc(snmpVarList.list, sizeof(SnmpVarBind) *snmpVarList.len);
 
        //Ouverture de Session
        session = SnmpMgrOpen("192.168.2.82","public",1000,3);
        if (session!=0)
        {
                SnmpMgrStrToOid(".1.3.6.1.2.1.17.4.3.1.2.0.20.56.185.112.146",&snmpVarList.list->name);
                //Envoi de la requete
                if (SnmpMgrRequest(session,SNMP_PDU_GET,&snmpVarList,&errorStatus,&errorIndex)!=0)
                {
                        if (errorStatus==SNMP_ERRORSTATUS_NOERROR)
                        {
 
                               //SnmpUtilPrintAsnAny(&snmpVarList.list->value);
                               HANDLE hOut;
                               char* buff="";
                               unsigned long *i;
                               SMALL_RECT *point;
                               INPUT_RECORD *buffbis;
 
                               hOut = CreateConsoleScreenBuffer(GENERIC_READ,FILE_SHARE_READ,NULL,CONSOLE_TEXTMODE_BUFFER,NULL);
 
                               SnmpUtilPrintAsnAny(&snmpVarList.list->value);
                               CordDef.X = 0;
                               CordDef.Y = 0;
                               ReadConsoleOutputCharacter(hOut,buff,256,CordDef,i);
 
                               cout<<buff;
                        }
                }
                //Fermeture de la session
                SnmpMgrClose(session);
                system("PAUSE");
        }
        return 0;
}