Aide pour traduction C++ vers Delphi
Bonjour à tous,
J'ai quelques problèmes de traduction d'une fonction C++.
Quelqu'un peut-il m'aider ?
Voici le code C++
Code:
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:
1 2 3 4 5
| typedef struct {
BYTE * stream;
UINT length;
BOOL dynamic;
} AsnOctetString; |
Et pMIB->pStorageValue de type
Code:
void * pStorageValue;
Voici ma traduction Delphi
Code:
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... :calim2:
Merci pour éventuel coup de main.