StrLComp、StrLIComp 与 StrComp、StrIComp 基本是一样的, 只是多了一个参数用来指定有效长度.
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
const
  s1 = 'abc123';
  s2 = 'ABC456';
var
  i: Integer;
begin
  i := StrLComp(PChar(s1), PChar(s2), 6);
  ShowMessage(IntToStr(i)); {32}

  i := StrLIComp(PChar(s1), PChar(s2), 6);
  ShowMessage(IntToStr(i)); {-3}

  i := StrLComp(PChar(s1), PChar(s2), 3);
  ShowMessage(IntToStr(i)); {32}

  i := StrLIComp(PChar(s1), PChar(s2), 3);
  ShowMessage(IntToStr(i)); {0}
end;

end.

SysUtils 单元下的公用函数目录

posted on 2008-05-12 16:52  万一  阅读(2451)  评论(0编辑  收藏  举报