⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 passtrng.pas

📁 《Delphi开发人员指南》配书原码
💻 PAS
字号:
unit PasStrng;
{ This unit maps some of the common String.h C++ RTL functions }
{ to their Object Pascal equivalent. }
{ Copyright (c) 1996, 1999 Steve Teixeira and Xavier Pacheco }

interface

uses Windows;

function _strcat(Dest, Source: PChar): PChar; cdecl;
procedure _memset(P: Pointer; Count: Integer; value: DWORD); cdecl;
function _stricmp(P1, P2: PChar): Integer; cdecl;
function _strlen(P1: PChar): Integer; cdecl;
function _strlwr(P1: PChar): PChar; cdecl;
function _strncat(Dest, Source: PChar; MaxLen: Integer): PChar; cdecl;
function _memcpy(Dest, Source: Pointer; Len: Integer): Pointer;
function _strncmp(P1, P2: PChar; MaxLen: Integer): Integer; cdecl;
function _strncmpi(P1, P2: PChar; MaxLen: Integer): Integer; cdecl;
function _memmove(Dest, Source: Pointer; Len: Integer): Pointer;
function _strncpy(Dest, Source: PChar; MaxLen: Integer): PChar; cdecl;
function _strnicmp(P1, P2: PChar; MaxLen: Integer): Integer; cdecl;
procedure _movmem(Source, Dest: Pointer; MaxLen: Integer); cdecl;
procedure _setmem(Dest: Pointer; Len: Integer; Value: Char); cdecl;
function _stpcpy(Dest, Source: PChar): PChar; cdecl;
function _strcmp(P1, P2: PChar): Integer; cdecl;
function _strstr(P1, P2: PChar): PChar; cdecl;
function _strcmpi(P1, P2: PChar): Integer; cdecl;
function _strupr(P: PChar): PChar; cdecl;
function _strcpy(Dest, Source: PChar): PChar; cdecl;

implementation

uses SysUtils;

function _strcat(Dest, Source: PChar): PChar;
begin
  Result := SysUtils.StrCat(Dest, Source);
end;

function _stricmp(P1, P2: PChar): Integer;
begin
  Result := StrIComp(P1, P2);
end;

function _strlen(P1: PChar): Integer;
begin
  Result := SysUtils.StrLen(P1);
end;

function _strlwr(P1: PChar): PChar;
begin
  Result := StrLower(P1);
end;

function _strncat(Dest, Source: PChar; MaxLen: Integer): PChar;
begin
  Result := StrLCat(Dest, Source, MaxLen);
end;

function _memcpy(Dest, Source: Pointer; Len: Integer): Pointer;
begin
  Move(Source^, Dest^, Len);
  Result := Dest;
end;

function _strncmp(P1, P2: PChar; MaxLen: Integer): Integer;
begin
  Result := StrLComp(P1, P2, MaxLen);
end;

function _strncmpi(P1, P2: PChar; MaxLen: Integer): Integer;
begin
  Result := StrLIComp(P1, P2, MaxLen);
end;

function _memmove(Dest, Source: Pointer; Len: Integer): Pointer;
begin
  Move(Source^, Dest^, Len);
  Result := Dest;
end;

function _strncpy(Dest, Source: PChar; MaxLen: Integer): PChar;
begin
  Result := StrLCopy(Dest, Source, MaxLen);
end;

procedure _memset(P: Pointer; Count: Integer; Value: DWORD);
begin
  FillChar(P^, Count, Value);
end;

function _strnicmp(P1, P2: PChar; MaxLen: Integer): Integer;
begin
  Result := StrLIComp(P1, P2, MaxLen);
end;

procedure _movmem(Source, Dest: Pointer; MaxLen: Integer);
begin
  Move(Source^, Dest^, MaxLen);
end;

procedure _setmem(Dest: Pointer; Len: Integer; Value: Char);
begin
  FillChar(Dest^, Len, Value);
end;

function _stpcpy(Dest, Source: PChar): PChar;
begin
  Result := StrCopy(Dest, Source);
end;

function _strcmp(P1, P2: PChar): Integer;
begin
  Result := StrComp(P1, P2);
end;

function _strstr(P1, P2: PChar): PChar;
begin
  Result := StrPos(P1, P2);
end;

function _strcmpi(P1, P2: PChar): Integer;
begin
  Result := StrIComp(P1, P2);
end;

function _strupr(P: PChar): PChar;
begin
  Result := StrUpper(P);
end;

function _strcpy(Dest, Source: PChar): PChar;
begin
  Result := StrCopy(Dest, Source);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -