IDesignerProgrammability::IsValidIdentifier

Checks whether a string represents a valid identifier in the host's programming environment.

HRESULT IsValidIdentifier(
   LPCOLESTR pszId
);

Parameter

pszId

[in] Pointer to a zero-terminated string.

Return Values

The return value obtained from HRESULT is one of the following:

Return Value Meaning
S_OK The string represents a valid identifier in the host's programming environment.
S_FALSE The string does not represent a valid identifier in the host's programming environment.

Comments

The IsValidIdentifier method checks whether the input string pszId represents a valid programmatic identifier in the host's programming environment. Designers should use this method to ensure that identifiers will be valid across multiple programming environments and in multiple programming languages.

Example

In the following example, m_pIDesignerProgrammability is a global variable that contains a pointer to the host's IDesignerProgrammability interface. The example calls the IsValidIdentifier method to find out whether the identifier in bstrId is valid within the host's environment. If so, the example sets a flag indicating that it's okay to add the identifier to the designer. If not, the example calls the MakeValidIdentifier method to create a new identifier in pszCleanId.

hr = m_pIDesignerProgrammability->IsValidIdentifier(bstrId);
if (hr == S_OK){
   bAdd = TRUE;
   }
else {
   pszCleanId = NULL;
   hr = m_piDesignerProgrammability-> MakeValidIdentifier(bstrId,
      &pszCleanId);
   }

See Also

IDesignerProgrammability::MakeValidIdentifier