The following example contains a function (ReadActivateTime) that reads a SCALAR_TIME scalar (Activate time) from a job folder (F_SYSTEMJOB, F_INSTALLJOB, F_SRVINSTALL, or F_REMPKGJOB):
// Function to read the Activate time scalar for a job folder
// and use printf to display the string equivalent of the time
// set for the scalar.
// This function uses SmsGetScalarByName.
SMS_STATUS ReadActivateTime(HANDLE hFolder) // Handle to job folder.
{
SMS_STATUS stat;
char *pszTime;
SCALAR sc;
char szName[SMS_DATA_BUFF_SIZE]; //Buffer for scalar name.
char szValue[BUFF_SIZE]; //Buffer for string equivalent.
sc.pszName = szName;
sc.pszValue = szValue;
sc.dwLen = sizeof(szValue)-1;
// Retrieve the scalar.
stat = SmsGetScalarByName(hFolder, // Handle to folder.
"Activate time", // Name of scalar to
// retrieve.
&sc // Pointer to SCALAR to
); // place scalar data.
if (sc.bStringEquivalence)
// if a string equivalent to time is provided,
// print the value.
printf("%s: %s\n", sc.pszName, sc.pszValue);
else {
// if no string equivalent, convert to string and print.
// Use ctime from C runtime library.
pszTime = ctime( &sc.tValue );
printf("%s: %s\n", sc.pszName, pszTime);
}
return(stat);
}