I have a record field "devDesc.VendorIdOffset", a Cardinal (ULONG) value
translated from an API hearder. It is the byte offset to a zero-terminated
ascii string containing the device's vendor id string.
The string length is 8.
I'm using a record pointer so the value at @pdevDesc.VendorIdOffset is what
I want to get into string variable 'VendorID'.
I have tried
VendorID := Copy(Pchar(@PdevDesc.VendorIdOffset),
PdevDesc.VendorIdOffset, 8)
and
VendorID := Format('%p', [@PdevDesc.VendorIdOffset, 8,
@PdevDesc.VendorIdOffset])
neither produces a name ... the format() one results in a string of
charaters, the other one makes a blank.
These C/C++ routines work.
I can't figure out how to translate them into Delphi/pascal.
VOID DebugPrint( USHORT DebugPrintLevel, PCHAR DebugMessage, ... )
{
va_list args;
va_start(args, DebugMessage);
if (DebugPrintLevel <= DebugLevel) {
char buffer[128];
(VOID) vsprintf(buffer, DebugMessage, args);
printf( "%s", buffer );
}
va_end(args);
}
// this uses the function above to format 'devDesc.VendorIdOffset'
if ( devDesc->VendorIdOffset && p[devDesc->VendorIdOffset] ) {
DebugPrint( 1, "Vendor ID : " );
for ( i = devDesc->VendorIdOffset; p[i] != (UCHAR) NULL && i
< returnedLength; i++ ) {
DebugPrint( 1, "%c", p[i] );
}
DebugPrint( 1, "
");
}
Thanks for any help,
Bill Mudd