一个完整身份证效验程序   根据〖中华人民共和国国家标准 GB 11643-1999〗中有关公民身份号码的规定, 
公民身份号码是特征组合码18位:由十七位数字本体码和一位数字校验码组成。排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位数字校验码。 
地址码表示编码对象常住户口所在县(市、旗、区)的行政区划代码。生日期码表示编码对象出生的年、月、日,其中年份用四位数字表示,年、月、日之间不用分隔符。顺序码表示同一地址码所标识的区域范围内,对同年、月、日出生的人员编定的顺序号。顺序码的奇数分给男性,偶数分给女性。 
15位:六位数字地址码,六位数字出生日期码,三位数字顺序码和一位数字校验码。 
var 
codeInfoTst: Tstrings; //总 
codeTst: Tstrings; //代码 
InfoTst: Tstrings; //地址信息 function identityInfo(identitycode: string): string; 
//由年月日判断是否为有效日期 
function IsDate(Year, Month, Day: string): Boolean; 
var 
st: string; 
begin st := Year + '-' + Month + '-' + day; 
try 
StrToDate(st); 
Result := True; 
except Result := False; end; 
end; 
function getdetailedFromCode(code: string): string; //由身份证的前六位获得省份县市信息 
var 
Index: integer; 
St: string; 
begin 
index := codeTst.IndexOf(code); 
if index = -1 then 
begin 
Result := ''; 
exit; 
end; 
st := infoTst[index]; //县 
code := copy(code, 1, 4) + '00'; 
index := codeTst.IndexOf(code); 
if index = -1 then 
begin 
Result := st; 
exit; 
end; 
st := infoTst[index] + st; //市 code := copy(code, 1, 2) + '0000'; 
index := codeTst.IndexOf(code); 
if index = -1 then 
begin 
Result := st; 
exit; 
end; 
st := infoTst[index] + st; //省 
Result := st; end; var 
YLYear, YLMonth, YlDay, id, sex, code: string; 
E: integer; 
St: string; begin 
e := Length(identitycode); 
if (e <> 18) or (e <> 15) then result := ''; 
if (e = 18) then 
begin 
YLYear := copy(identitycode, 7, 4); 
YlMonth := copy(identitycode, 11, 2); 
YLday := copy(identitycode, 13, 2); 
id := copy(identitycode, 18,1); 
end; 
if (e = 15) then 
begin 
YLYear := '19' + copy(identitycode, 7, 2); 
YlMonth := copy(identitycode, 9, 2); 
YLday := copy(identitycode, 11, 2); 
id := copy(identitycode, 15, 1); 
end; 
st := ''; 
if IsDate(YlYear, YlMonth, Ylday) then 
begin 
st := YLYear + '年' + YlMonth + '月' + YLday + '日生' 
end; 
code := copy(identitycode, 1, 6); 
st := getdetailedFromCode(code) + ':' + st; 
if (StrToInt(id) mod 2 = 1) then 
begin 
sex := '男'; 
end 
else 
begin 
sex := '女'; 
end; 
st := st + ':' + sex + '性!' + Trim(IntToStr(e)) + '位证号!'; 
Result := st; end; procedure TForm1.Button1Click(Sender: TObject); 
var 
i, num: integer; 
code, info: string; 
begin 
codeInfoTst := Tstringlist.Create; 
CodeTst := Tstringlist.Create; 
infotst := Tstringlist.Create; 
try 
codeInfoTst.LoadFromFile('c:\code.txt'); 
//分解代码地址信息 
num := Codeinfotst.Count; 
for i := 0 to num - 1 do 
begin 
code := copy(Codeinfotst[i], 1, 6); 
Info := copy(Codeinfotst[i], 8, length(Codeinfotst[i]) - 7); 
codetst.Add(code); 
infotst.Add(info); end; 
showmessage(identityInfo('530101700205379')); finally 
codeTst.Free; 
infotst.Free; 
CodeinfoTst.Free; 
end; end; end.

解决方案 »

  1.   

    公安局有,托熟人去copy或到公安局的网站去找找!
      

  2.   

    up!
    ------------------------------------------------
    给朋友送手机图片、铃声,请到: oksms.sms.163.com
      

  3.   

    对身份证的一些简单的校as验
    1 2 3 4 5
    XX XXXX XXXXXX XX X 这个是没有升位以前的一个身份证号码的组成方式1 表示省 2 表示 地市 3 生日 4 顺序码 5 性别
    其他的校验 都很简单或者无法校验 我在这里给大家提供一个我珍藏多年的一个数据,对籍贯进行校验
    查看用户填写的身份证号码的 1 部分时候和 选择的籍贯一致,下面就是我国目前所有的 籍贯划分代码
    北京 11
    天津 12
    河北 13
    山西 14
    内蒙古 15
    辽宁 21
    吉林 22
    黑龙江 23
    上海 31
    江苏 32
    浙江 33
    安徽 34
    福建 35
    江西 36
    山东 37
    河南 41
    湖北 42
    湖南 43
    广东 44
    广西 45
    海南 46
    重庆 50
    四川 51
    贵州 52
    云南 53
    西藏 54
    陕西 61
    甘肃 62
    青海 63
    宁夏 64
    新疆 65
    台湾 71
    香港 81
    澳门 82
    国外 91呵呵,当然 这些信息只能给我们提供尽可能的准确的信息
      

  4.   

    你那对照表格给我发一份好吗?谢谢了!
    [email protected]
      

  5.   

    我要的是详细的阿;[email protected]
    带地区的,到区为止
      

  6.   

    是详细的,,,,到县一级呵呵。。我的宝贝啊可惜上传CSDN没有成功
      

  7.   

    结贴说明:
    这么多人好热心,我可怎么给分呢;
    这个贴子先给suhu(zym)吧,回头我马上发个贴子给大家分;一个不会少
    suhu(zym)给我发过来了详细的,回头一起给大家;谢谢
      

  8.   

    lovingkiss(你要答案我要分) 给我也发一份吧,谢谢!!!
    [email protected]
      

  9.   

    give me a copy,[email protected]