StrCmpLogicalW字符串逻辑比较函数

StrCmpLogicalW字符串逻辑比较函数,字符串中的数字会根据数字顺序进行排序
比如如下系列
a_1.xml
a_20.xml
a_10.xml
a_2.XML

正常字符串排序后会是

a_1.xml
a_10.xml
a_2.xml
a_20.XML

而字符串逻辑排序后是

a_1.xml
a_2.xml
a_10.xml
a_20.XML
StrCmpLogicalW是windows自带API函数,delphi中没有声明,使用时需要声明才能使用。
function StrCmpLogicalW(psz1, psz2: PWideChar): Integer; stdcall;
  external 'shlwapi.dll';

function StrCmpLogical(const s1, s2: string): Integer;
begin
  Result := StrCmpLogicalW(PChar(s1), PChar(s2));
end;

 

posted @ 2020-11-10 13:09  dqi1999  阅读(793)  评论(0)    收藏  举报