The SmsGetScalarByName function retrieves the scalar with the specified scalar name from the specified folder and writes the scalar's information into a SCALAR structure.
SMS_STATUS SmsGetScalarByName(
HANDLE hFolder, // Handle to folder.
const char *pszName, // Pointer to string containing the name of
// the scalar.
SCALAR *pScalarStruct // Pointer to SCALAR structure to receive
// scalar data.
);
Note that SmsGetScalarByName cannot be used to retrieve scalars from a persistent filter. Scalars for persistent filters can be retrieved in sequence only (by using SmsGetNextScalar).
If the scalar is of type SCALAR_STRING or SCALAR_BINARY, your application must ensure that the buffer for the string or binary is large enough for the value of the scalar. Note that the pszValue member points to a string buffer and the pValue member points to a buffer for a binary.
To get the correct size for the buffers, call the SmsGetScalarByName function with the dwLen member of the pScalarStruct structure set to NULL. SmsGetScalarByName will assign the size of the string or binary value and return a status of SMS_MORE_DATA. After getting the size of the value, create a buffer large enough for the value and assign a pointer to that buffer to the pszValue member for SCALAR_STRING or pValue for SCALAR_BINARY. Then call the SmsGetScalarByName function again using a pScalarStruct structure with the correct size for dwLen and a pointer to a sufficiently sized buffer for the pszValue (SCALAR_STRING) or pValue (SCALAR_BINARY).
Caution Some string scalars may contain embedded control characters. For example, the STRING_1 through STRING_10 attributes for folders with the SMSEvent architecture contain embedded newline and other control characters. Your application is responsible for detecting and handling these control characters.
The SmsGetScalarByName function returns a status code SMS_STATUS. If successful, the function returns a status of SMS_OK. Otherwise, it returns one of the following manifest constants:
Scalars can be retrieved in sequence or by the scalar name. To retrieve scalars in sequence, use the SmsGetNextScalar function. To retrieve scalars by scalar name, use the SmsGetScalarByName function.
SmsDescribeFolder, SmsGetNextScalar