Skip to content

EnumFromName

Converts the string name of an enum value to its numeric value.

template <typename T>
bool EnumFromName(const CString& strName, T& enumVal) const;

strName

[in] String name of an enum value.

enumVal

[out] Enum value associated with the specified name.

Returns true if the conversion was successful, otherwise false.

The following example demonstrates use of the EnumFromName function.

CoAcme4321.cpp
HRESULT Acme4321::ConfigureTrigger()
{
HRESULT hr = S_OK;
IviFgenTriggerSource eSource;
EnumFromString(_T("IviFgenTriggerSourceInternal"), eSource);
ATLASSERT(eSource == IviFgenTriggerSourceInternal);
return hr;
}