Currently, only program item folders contain a scalar of type SCALAR_BINARY. The Icon scalar in a program item folder is a binary scalar that specifies an icon resource that will be used as the icon for the program item.
The following example contains a function (GetProgItemIcon) that reads a SCALAR_BINARY scalar (Icon) from a program item folder (F_PROGITEM):
//***********************************************************
// Function to retrieve Icon binary scalar from
// a program item folder.
//***********************************************************
SMS_STATUS ReadIcon(HANDLE hFolder)
{
SMS_STATUS stat;
SCALAR sc;
char szName[SMS_DATA_BUFF_SIZE]; // buffer for name
char szValue[SMS_DATA_BUFF_SIZE]; // buffer for value
BYTE *pbyteValue;
sc.pszName = szName;
sc.pszValue = szValue;
sc.pValue = NULL;
sc.dwLen = NULL;
sc.scType = SCALAR_BINARY;
// Call SmsGetScalarByName with dwLen set to NULL
// to get length of binary data.
stat = SmsGetScalarByName( hFolder,
"Icon",
&sc);
// if length is returned, allocate memory for the
// data buffer .
if (stat == SMS_MORE_DATA) {
printf("Binary scalar \"%s\" has length of %d bytes\n",
sc.pszName, sc.dwLen);
// Allocate memory for the binary data.
sc.pValue = pbyteValue;
pbyteValue = (BYTE *) malloc(sc.dwLen);
// Call SmsGetScalarByName again
// to retrieve the binary scalar.
stat = SmsGetScalarByName( hFolder,
"Icon",
&sc);
}
if (stat == SMS_OK) {
// Data retrieved successfully.
printf("Binary scalar \"%s\" has %d bytes of binary data\n",
sc.pszName, sc.dwLen);
// Primitive dump of the data.
for (DWORD dwI = 0; dwI < sc.dwLen; dwI++) {
printf("%0X ", pbyteValue[dwI]);
}
printf("\n");
}
// if scalar cannot be retrieved,
// print status code.
else {
printf("Cannot retrieve binary scalar \"%s\".", sc.pszName);
printf("Error in SmsGetScalarByName: %d.\n", stat);
}
// Free allocated memory and return
// the status code.
free(pbyteValue);
return stat;
}