Returns a counted array of string pointers (LPOLESTR pointers). The strings pointed to provide a list of names that each correspond to values that the property specified with dispID can accept.
HRESULT GetPredefinedStrings(
DISPID dispID, //Dispatch identifier for property
CALPOLESTR *pcaStringsOut, //Receives a pointer to an array of
//strings
CADWORD *pcaCookiesOut //Receives a pointer to array of DWORDs
);
This method supports the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following:
Each string returned in the array pointed to by pcaStringsOut has a matching token in the counted array pointed to by pcaCookiesOut, where the token can be passed to IPerPropertyBrowsing::GetPredefinedValue to get the actual value (a VARIANT) corresponding to the string.
Using the predefined strings, a caller can obtain a list of strings for populating user interface elements, such as a drop-down listbox. When the end user selects one of these strings as a value to assign to a property, the caller can then obtain the corresponding value through IPerPropertyBrowsing::GetPredefinedValue.
Both the CALPOLESTR and CADWORD structures passed to this method are caller-allocated. The caller is responsible for freeing each string pointed to from the CALPOLESTR array as well as the CALPOLESTR structure.
All memory is allocated with CoTaskMemAlloc. The caller is responsible for freeing the strings and the array with CoTaskMemFree.
Upon return from this method, the caller is responsible for all this memory and must free it when it is no longer needed. Code to achieve this appears as follows:
CALPOLESTR castr;
CWDWORD cadw;
ULONG i;
pIPerPropertyBrowsing->GetPredefinedStrings(dispID, &castr, &cadw);
//...Use the strings and the cookies
CoTaskMemFree((void *)cadw.pElems);
for (i=0; i < castr.cElems; i++)
CoTaskMemFree((void *)castr.pElems[i]);
CoTaskMemFree((void *)castr.pElems);
Support for predefined names and values is not required. If your object does not support these names, return E_NOTIMPL from this method. If this method is not implemented, IPerPropertyBrowsing::GetPredefinedValue must not be implemented either.
This method fills the cElems and pElems fields of the CADWORD and CALPOLESTR structures. It allocates the arrays pointed to by these structures with CoTaskMemAlloc and fills those arrays. In the CALPOLESTR case, this method also allocates each string with CoTaskMemAlloc, storing each string pointer in the array.
Windows NT: Use version 4.0 or later.
Windows: Use Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in ocidl.h.
CADWORD, CALPOLESTR, CoTaskMemAlloc, CoTaskMemFree, IPerPropertyBrowsing::GetPredefinedValue