function ValidatePID(const APID: string): string;
{内部函数,取身份证号校验位,最后一位,对18位有效}
function GetVerifyBit(sIdentityNum: string): Char;
var nNum: Integer;
begin
Result := #0;
nNum := StrToInt(sIdentityNum[1]) * 7 +
StrToInt(sIdentityNum[2]) * 9 +
StrToInt(sIdentityNum[3]) * 10 +
StrToInt(sIdentityNum[4]) * 5 +
StrToInt(sIdentityNum[5]) * 8 +
StrToInt(sIdentityNum[6]) * 4 +
StrToInt(sIdentityNum[7]) * 2 +
StrToInt(sIdentityNum[8]) * 1 +
StrToInt(sIdentityNum[9]) * 6 +
StrToInt(sIdentityNum[10]) * 3 +
StrToInt(sIdentityNum[11]) * 7 +
StrToInt(sIdentityNum[12]) * 9 +
StrToInt(sIdentityNum[13]) * 10 +
StrToInt(sIdentityNum[14]) * 5 +
StrToInt(sIdentityNum[15]) * 8 +
StrToInt(sIdentityNum[16]) * 4 +
StrToInt(sIdentityNum[17]) * 2;
nNum := nNum mod 11;
case nNum of
0: Result := '1';
1: Result := '0';
2: Result := 'X';
3: Result := '9';
4: Result := '8';
5: Result := '7';
6: Result := '6';
7: Result := '5';
8: Result := '4';
9: Result := '3';
10:Result := '2';
end;
end;
var
L,iCentury,iMonth,iDate: Integer;
sCentury,sYear2Bit,sMonth,sDate : string;
CRCFact: string;//18位证号的实际值
CRCTh: string; //18位证号的理论值
FebDayAmt: Byte;//2月天数
begin
L := Length(APID);
if (L in [15, 18]) = False then
begin
Result := Format('身份证号不是15位或18位(%0:s, 实际位数:%1:d)', [APID, L]);
Exit;
end;
CRCFact := '';
{内部函数,取身份证号校验位,最后一位,对18位有效}
function GetVerifyBit(sIdentityNum: string): Char;
var nNum: Integer;
begin
Result := #0;
nNum := StrToInt(sIdentityNum[1]) * 7 +
StrToInt(sIdentityNum[2]) * 9 +
StrToInt(sIdentityNum[3]) * 10 +
StrToInt(sIdentityNum[4]) * 5 +
StrToInt(sIdentityNum[5]) * 8 +
StrToInt(sIdentityNum[6]) * 4 +
StrToInt(sIdentityNum[7]) * 2 +
StrToInt(sIdentityNum[8]) * 1 +
StrToInt(sIdentityNum[9]) * 6 +
StrToInt(sIdentityNum[10]) * 3 +
StrToInt(sIdentityNum[11]) * 7 +
StrToInt(sIdentityNum[12]) * 9 +
StrToInt(sIdentityNum[13]) * 10 +
StrToInt(sIdentityNum[14]) * 5 +
StrToInt(sIdentityNum[15]) * 8 +
StrToInt(sIdentityNum[16]) * 4 +
StrToInt(sIdentityNum[17]) * 2;
nNum := nNum mod 11;
case nNum of
0: Result := '1';
1: Result := '0';
2: Result := 'X';
3: Result := '9';
4: Result := '8';
5: Result := '7';
6: Result := '6';
7: Result := '5';
8: Result := '4';
9: Result := '3';
10:Result := '2';
end;
end;
var
L,iCentury,iMonth,iDate: Integer;
sCentury,sYear2Bit,sMonth,sDate : string;
CRCFact: string;//18位证号的实际值
CRCTh: string; //18位证号的理论值
FebDayAmt: Byte;//2月天数
begin
L := Length(APID);
if (L in [15, 18]) = False then
begin
Result := Format('身份证号不是15位或18位(%0:s, 实际位数:%1:d)', [APID, L]);
Exit;
end;
CRCFact := '';