StrToInt

Declaration

int StrToInt (LPCTSTR lpSrc);

The function exists in both ANSI and Unicode forms.

Parameters

The lpSrc argument provides the address of characters to interpret as a signed decimal integer.

Return Value

The function returns its evaluation of the signed decimal integer, defaulting to zero.

Behaviour

If lpSrc is NULL, there is no input string to parse, and the function returns zero. Otherwise, the function parses the characters at lpSrc as follows:

Evaluation proceeds for as many decimal digits as are provided. The function returns the least significant 32 bits of the evaluation, negated if a minus sign was given.

Availability

The StrToInt function is exported by name (with both ANSI and Unicode suffixes) from SHLWAPI.DLL version 4.70 and higher. An identical implementation is also exported from COMCTL32.DLL as ordinals 357 and 365 in version 3.50 and higher, though the Unicode form is not present in the version 4.00 from Windows 95.

This function has been documented since some time in 1997-98. Though it dates from 1996 in SHLWAPI and from 1995 elsewhere, it has always been said to require at least SHLWAPI version 4.71.

Microsoft’s documentation is explicit in allowing white space as the first characters at lpSrc and allowing either a plus or minus sign. Both points are true of the StrToIntEx function but not of plain, ordinary StrToInt. Presumably, the latter has never been important enough for anyone to bother checking what’s actually coded.