(SST) ShlWAPI.pas Version 1.08

Developer Reference
(SST)ShlWAPI StrCSpnI Function
Performs a case insensitive character search, for multiple characters, on the specified string.
Scope
Global (i.e. this function can be called/accessed from code in any unit that includes/uses (SST)ShlWAPI.pas).
Syntax
function StrCSpnI(lpStr : LPCSTR; lpSet : LPCSTR) : Integer;
Parameters
lpStr [in] Pointer to the null-terminated string in which to search for the character(s) listed in lpSet.
lpSet [in] Pointer to a null-terminated string that consists of the character to search for. As the search for the listed characters is not case sensitive, printable characters may be specified either as lower- or upper-case characters.
Return Values
If the string to be searched (lpStr) contained any of the characters that are in the list of characters to search for (lpSet), the function returns the 0-based index of the first occurrence of the character it found. If the specified string (lpStr) does not contain any of the characters listed in the string of characters to search for (lpSet), it returns the length of the string to be searched.
Remarks
StrCSpnI can also be used to search for non-printable characters (e.g. blanks, carriage returns, etc.), see last example, below.
Although the function's functionality differs from that of StrCSpn only in that it performs a case-insensitive search, the results when printable characters (e.g. a, B, W, x) are specified in the parameter lpSet, can be significant.
Example
PROCEDURE TForm4.TestShlWAPIStrCSpnI(Sender : TObject); VAR txttosearch : STRING; VAR txttosrchlen : INTEGER; VAR charsettosrch : STRING; VAR apiretval : INTEGER; VAR newinfoline : STRING; BEGIN txttosearch := ''; txttosrchlen := 0; charsettosrch := ''; apiretval := 0; newinfoline := ''; txttosearch := 'This function''s functionality is a little easier easier to understand.'; txttosrchlen := Length(txttosearch); charsettosrch := 'w'; newinfoline := 'StrCSpnI called with "' + txttosearch + '" and "' + charsettosrch + '"'; Memo1.Lines.Add(newinfoline); apiretval := StrCSpnI(PChar(txttosearch), PChar(charsettosrch)); IF apiretval <> txttosrchlen THEN newinfoline := 'StrCSpnI returned ' + IntToStr(apiretval) ELSE newinfoline := 'StrCSpnI did not find any of the listed characters.'; Memo1.Lines.Add(newinfoline); txttosearch := 'This function''s functionality is a little easier easier to understand.'; charsettosrch := 'wm'; newinfoline := 'StrCSpnI called with "' + txttosearch + '" and "' + charsettosrch + '"'; Memo1.Lines.Add(newinfoline); apiretval := StrCSpnI(PChar(txttosearch), PChar(charsettosrch)); IF apiretval <> txttosrchlen THEN newinfoline := 'StrCSpnI returned ' + IntToStr(apiretval) ELSE newinfoline := 'StrCSpnI did not find any of the listed characters.'; Memo1.Lines.Add(newinfoline); txttosearch := 'This function''s functionality is a little easier easier to understand.'; charsettosrch := 'wme'; newinfoline := 'StrCSpnI called with "' + txttosearch + '" and "' + charsettosrch + '"'; Memo1.Lines.Add(newinfoline); apiretval := StrCSpnI(PChar(txttosearch), PChar(charsettosrch)); IF apiretval <> txttosrchlen THEN newinfoline := 'StrCSpnI returned ' + IntToStr(apiretval) ELSE newinfoline := 'StrCSpnI did not find any of the listed characters.'; Memo1.Lines.Add(newinfoline); txttosearch := 'This function''s functionality is a little easier easier to understand.'; charsettosrch := 'wmf'; newinfoline := 'StrCSpnI called with "' + txttosearch + '" and "' + charsettosrch + '"'; Memo1.Lines.Add(newinfoline); apiretval := StrCSpnI(PChar(txttosearch), PChar(charsettosrch)); IF apiretval <> txttosrchlen THEN newinfoline := 'StrCSpnI returned ' + IntToStr(apiretval) ELSE newinfoline := 'StrCSpnI did not find any of the listed characters.'; Memo1.Lines.Add(newinfoline); txttosearch := 'This function''s functionality is a little easier easier to understand.'; charsettosrch := 'FW'; newinfoline := 'StrCSpnI called with "' + txttosearch + '" and "' + charsettosrch + '"'; Memo1.Lines.Add(newinfoline); apiretval := StrCSpnI(PChar(txttosearch), PChar(charsettosrch)); IF apiretval <> txttosrchlen THEN newinfoline := 'StrCSpnI returned ' + IntToStr(apiretval) ELSE newinfoline := 'StrCSpnI did not find any of the listed characters.'; Memo1.Lines.Add(newinfoline); txttosearch := 'This function''s functionality is a little easier easier to understand.'; charsettosrch := 'F W'; //Note the blank between F and W ! newinfoline := 'StrCSpnI called with "' + txttosearch + '" and "' + charsettosrch + '"'; Memo1.Lines.Add(newinfoline); apiretval := StrCSpnI(PChar(txttosearch), PChar(charsettosrch)); IF apiretval <> txttosrchlen THEN newinfoline := 'StrCSpnI returned ' + IntToStr(apiretval) ELSE newinfoline := 'StrCSpnI did not find any of the listed characters.'; Memo1.Lines.Add(newinfoline); txttosearch := 'This function''s functionality is ' + #13 + #10 + 'a little easier easier to understand.'; charsettosrch := 'F' + #13 + 'W'; //Note the carriage return between F and W ! newinfoline := 'StrCSpnI called with "' + txttosearch + '" and "' + charsettosrch + '"'; Memo1.Lines.Add(newinfoline); apiretval := StrCSpnI(PChar(txttosearch), PChar(charsettosrch)); IF apiretval <> txttosrchlen THEN newinfoline := 'StrCSpnI returned ' + IntToStr(apiretval) ELSE newinfoline := 'StrCSpnI did not find any of the listed characters.'; Memo1.Lines.Add(newinfoline); Memo1.Lines.Add(''); END;
The above example produces the following output:
StrCSpnI called with "This function's functionality is a little easier easier to understand." and "w" StrCSpnI did not find any of the listed characters. StrCSpnI called with "This function's functionality is a little easier easier to understand." and "wm" StrCSpnI did not find any of the listed characters. StrCSpnI called with "This function's functionality is a little easier easier to understand." and "wme" StrCSpnI returned 40 StrCSpnI called with "This function's functionality is a little easier easier to understand." and "wmf" StrCSpnI returned 5 StrCSpnI called with "This function's functionality is a little easier easier to understand." and "FW" StrCSpnI returned 5 StrCSpnI called with "This function's functionality is a little easier easier to understand." and "F W" StrCSpnI returned 4 StrCSpnI called with "This function's functionality is a little easier easier to understand." and "F W" StrCSpnI returned 5
Requirements
Unit: Declared and imported in (SST)ShlWAPI.pas
Library: (SST)ShlWAPI.dcu/(SST)ShlWAPI.obj
Unicode: Implemented as ANSI (StrCSpnI and StrCSpnIA) and Unicode (StrCSpnIW) functions.
Min. ShlWAPI.dll version according to MS SDK doc.: 4.71
Min. ShlWAPI.dll version based on SST research: 4.71
Min. OS version(s) according to Microsoft SDK doc.: Windows 2000, Windows NT 4.0 with Internet Explorer 4.0, Windows 98, Windows 95 with Internet Explorer 4.0
Min. OS version(s) according to SST research.: Windows NT 4.0 with IE 4.0, Windows 95 with IE 4.0, Windows 98, Windows 2000 and later
See Also
StrCSpn, StrSpn.
 
Windows APIs: GetLastError, SetLastError StrCSpn StrCSpnI


Document/Contents version 1.00
Page/URI last updated on May 04, 2022
 
Copyright © Stoelzel Software Technologie (SST) 2010 - 2015
Suggestions and comments mail to:
webmaster@stoelzelsoftwaretech.com