Example of Retrieving a SCALAR_STRING Scalar

The following example contains a function (ReadPackageID) that reads a SCALAR_STRING scalar (Package ID) from a job folder (F_SYSTEMJOB, F_INSTALLJOB, F_SRVINSTALL, or F_REMPKGJOB):

// Function to read the Package ID scalar for a job folder
// and use printf to display the scalar.
// This function uses SmsGetScalarByName.

SMS_STATUS ReadPackageID(HANDLE hFolder) // Handle to job folder.

{
SMS_STATUS stat;
SCALAR sc;
char szName[SMS_DATA_BUFF_SIZE]; //Buffer for scalar name.
char szValue[9]; //Buffer for string value. Package ID is 8 char.
sc.pszName = szName;
sc.pszValue = szValue;
sc.dwLen = sizeof(szValue)-1;
sc.scType = SCALAR_STRING;

// Retrieve the scalar.
stat = SmsGetScalarByName(hFolder,      // Handle to folder.
                          "Package ID", // Name of scalar to 
                                        // retrieve.
                          &sc           // Pointer to SCALAR to 
                                        // place scalar data.
                          );
// print the value.
printf("%s: %s\n", sc.pszName, sc.pszValue);
return(stat);
}