![]() |
(SST) ShlWAPI.pas Version 1.08 |
---|---|
Developer Reference |
Performs a case sensitive 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). |
Parameters | |
---|---|
lpStr [in] |
Pointer to the null-terminated string in which to search for the |
lpSet [in] | Pointer to a null-terminated string that consists of the character to search for. |
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 (lpSet) 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 |
---|
StrCSpn can also be used to search for non-printable characters (e.g. blanks, carriage returns, etc.). |
Example |
---|
PROCEDURE TForm4.TestShlWAPIStrCSpn(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 somewhat easier to understand.'; txttosrchlen := Length(txttosearch); charsettosrch := 'w'; newinfoline := 'StrCSpn called with "' + txttosearch + '" and "' + charsettosrch + '"'; Memo1.Lines.Add(newinfoline); apiretval := StrCSpn(PChar(txttosearch), PChar(charsettosrch)); IF apiretval <> txttosrchlen THEN newinfoline := 'StrCSpn returned ' + IntToStr(apiretval) ELSE newinfoline := 'StrCSpn did not find any of the listed characters.'; Memo1.Lines.Add(newinfoline); txttosearch := 'This function''s functionality is somewhat easier to understand.'; charsettosrch := 'wm'; newinfoline := 'StrCSpn called with "' + txttosearch + '" and "' + charsettosrch + '"'; Memo1.Lines.Add(newinfoline); apiretval := StrCSpn(PChar(txttosearch), PChar(charsettosrch)); IF apiretval <> txttosrchlen THEN newinfoline := 'StrCSpn returned ' + IntToStr(apiretval) ELSE newinfoline := 'StrCSpn did not find any of the listed characters.'; Memo1.Lines.Add(newinfoline); txttosearch := 'This function''s functionality is somewhat easier to understand.'; charsettosrch := 'wme'; newinfoline := 'StrCSpn called with "' + txttosearch + '" and "' + charsettosrch + '"'; Memo1.Lines.Add(newinfoline); apiretval := StrCSpn(PChar(txttosearch), PChar(charsettosrch)); IF apiretval <> txttosrchlen THEN newinfoline := 'StrCSpn returned ' + IntToStr(apiretval) ELSE newinfoline := 'StrCSpn did not find any of the listed characters.'; Memo1.Lines.Add(newinfoline); txttosearch := 'This function''s functionality is somewhat easier to understand.'; charsettosrch := 'wmf'; newinfoline := 'StrCSpn called with "' + txttosearch + '" and "' + charsettosrch + '"'; Memo1.Lines.Add(newinfoline); apiretval := StrCSpn(PChar(txttosearch), PChar(charsettosrch)); IF apiretval <> txttosrchlen THEN newinfoline := 'StrCSpn returned ' + IntToStr(apiretval) ELSE newinfoline := 'StrCSpn did not find any of the listed characters.'; Memo1.Lines.Add(newinfoline); txttosearch := 'This function''s functionality is somewhat easier to understand.'; charsettosrch := 'FW'; newinfoline := 'StrCSpn called with "' + txttosearch + '" and "' + charsettosrch + '"'; Memo1.Lines.Add(newinfoline); apiretval := StrCSpn(PChar(txttosearch), PChar(charsettosrch)); IF apiretval <> txttosrchlen THEN newinfoline := 'StrCSpn returned ' + IntToStr(apiretval) ELSE newinfoline := 'StrCSpn did not find any of the listed characters.'; Memo1.Lines.Add(newinfoline); txttosearch := 'This function''s functionality is somewhat easier to understand.'; charsettosrch := 'F W'; //Note the blank between F and W ! newinfoline := 'StrCSpn called with "' + txttosearch + '" and "' + charsettosrch + '"'; Memo1.Lines.Add(newinfoline); apiretval := StrCSpn(PChar(txttosearch), PChar(charsettosrch)); IF apiretval <> txttosrchlen THEN newinfoline := 'StrCSpn returned ' + IntToStr(apiretval) ELSE newinfoline := 'StrCSpn did not find any of the listed characters.'; Memo1.Lines.Add(newinfoline); txttosearch := 'This function''s functionality is ' + #13 + #10 + 'somewhat easier to understand.'; charsettosrch := 'F' + #13 + 'W'; //Note the carriage return between F and W ! newinfoline := 'StrCSpn called with "' + txttosearch + '" and "' + charsettosrch + '"'; Memo1.Lines.Add(newinfoline); apiretval := StrCSpn(PChar(txttosearch), PChar(charsettosrch)); IF apiretval <> txttosrchlen THEN newinfoline := 'StrCSpn returned ' + IntToStr(apiretval) ELSE newinfoline := 'StrCSpn did not find any of the listed characters.'; Memo1.Lines.Add(newinfoline); Memo1.Lines.Add(''); END; |
The above example produces the following output: |
StrCSpn called with "This function's functionality is somewhat easier to understand." and "w" StrCSpn returned 37 StrCSpn called with "This function's functionality is somewhat easier to understand." and "wm" StrCSpn returned 35 StrCSpn called with "This function's functionality is somewhat easier to understand." and "wme" StrCSpn returned 35 StrCSpn called with "This function's functionality is somewhat easier to understand." and "wmf" StrCSpn returned 5 StrCSpn called with "This function's functionality is somewhat easier to understand." and "FW" StrCSpn did not find any of the listed characters. StrCSpn called with "This function's functionality is somewhat easier to understand." and "F W" StrCSpn returned 4 StrCSpn called with "This function's functionality is somewhat easier to understand." and "F W" StrCSpn returned 33 |
Requirements | |
---|---|
Unit: | Declared and imported in (SST)ShlWAPI.pas |
Library: | (SST)ShlWAPI.dcu/(SST)ShlWAPI.obj |
Unicode: | Implemented as ANSI (StrCSpn and StrCSpnA) and Unicode (StrCSpnW) 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 |
Document/Contents version 1.00 Page/URI last updated on 07.12.2023 |
Copyright © Stoelzel Software Technologie (SST) 2010 - 2017 |
Suggestions and comments mail to: webmaster@stoelzelsoftwaretech.com |