At 10:27 AM -0500 1999/12/13, Charles Rezsonya wrote:
> retval = SysGetROMToken (0, sysROMTokenSnum, (BytePtr*) &bufP, &bufLen);
>
>gives me the ID of the unit. but since it doesn't null terminate it i get
>extra characters in the variable. how can i terminate it and have it moved
>to other variables for me to manipulate it with? i try a strcopy but all
>char's after the id are passed with it.
>
>is there a definate length that the ID will always be? can i do a strNcopy
>instead to remove the extra chars?
bufP tell you where the data is located (in ROM), bufLen tells you how many bytes it
is... so allocate bufLen + 1 bytes of memory either dynamically or on the stack,
memcpy the data, then terminate like a C string. You could use StrNCopy on
single-byte-character versions of the Palm OS for this, but keep in mind the serial
number ROM token is not a plain C string -- rather a sequence of displayable
single-byte characters, between 0 and 12 bytes in length. Remember to carefully follow
the devsup sample code (specifically the if-statement) below:
CharPtr bufP;
Word bufLen;
Word retval;
retval = SysGetROMToken (0, sysROMTokenSnum, (BytePtr*) &bufP, &bufLen);
if ((!retval) && (bufP) && ((Byte) *bufP != 0xFF)) {
// it's valid!
WinDrawChars(bufP, bufLen, 20, 50);
}
else
// do something else; we don't have a serial number.
Regards,
Jim Schram
3Com/Palm Computing
Partner Engineering