Bonjour à tous,

J'ai quelques problèmes de traduction d'une fonction C++.
Quelqu'un peut-il m'aider ?

Voici le code C++
Code C++ : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
pasnValue->asnValue.string.length = strlen(*(LPSTR*)pMIB->pStorageValue);
pasnValue->asnValue.string.stream =(unsigned char*)SnmpUtilMemAlloc(pasnValue->asnValue.string.length * sizeof(char));
 
memcpy(pasnValue->asnValue.string.stream,*(LPSTR*)pMIB->pStorageValue,pasnValue->asnValue.string.length);
pasnValue->asnValue.string.dynamic = TRUE;
Avec pasnValue->asnValue.string de type
Code C++ : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
typedef struct {
    BYTE * stream;
    UINT   length;
    BOOL   dynamic;
} AsnOctetString;

Et pMIB->pStorageValue de type
Code C++ : Sélectionner tout - Visualiser dans une fenêtre à part
void * pStorageValue;
Voici ma traduction Delphi
Code Delphi : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
asnValue.asnValue.str.length := PChar(MIB.pStorageValue);
asnValue.asnValue.str.stream := SnmpUtilMemAlloc(asnValue.asnValue.str.length * SizeOf(Char));
 
CopyMemory(asnValue.asnValue.str.stream, PChar(MIB.pStorageValue), Length(PChar(MIB.pStorageValue)));
asnValue.asnValue.str.dynam := True;
Mon problème est que je ne récupère que la première lettre de la chaîne...

Merci pour éventuel coup de main.