Useful Conversion in C++

0.00 avg. rating (0% score) - 0 votes

BYTE[] to DWORD:

BYTE tzValue[4];

DWORD value = tzValue[3]*16*16*16 + tzValue[2]*16*16 + tzValue[1]*16 + tzValue[0];

Print hexadecimal:

printf(“Value: 0x%08lxn”, value);

BYTE[] to WCHAR:

BYTE tzValue[MAX_PATH];

WCHAR* strDest = (WCHAR*) &tzValue[0];

Merge 2 WORDs into a DWORD:

WORD wLow;

WORD wHigh;

DWORD dw = wLow + 0x1000*wHigh;

BSTR to (char*)

BSTR st;

char* st = (const char*)_bstr_t(st);


0.00 avg. rating (0% score) - 0 votes
ToughDev

ToughDev

A tough developer who likes to work on just about anything, from software development to electronics, and share his knowledge with the rest of the world.

Leave a Reply