摘自:http://www.powerba.com/develop/delphi/article/20000927030.htm
function f(ID: string):string;
const
W:array [1..18] of integer = (7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1);
A:array [0..10] of char = ('1','0','x','9','8','7','6','5','4','3','2');
var
i, j, S: integer;
NewID: string;
begin
if Length(ID) <> 15 then
result:= ''
else begin
NewID:= ID;
Insert('19', NewID, 7);
S:= 0;
try
for i:=1 to 17 do begin
j:= StrToInt(NewID) * W;
S:= S + j;
end;
except
result:= '';
exit;
end;
S:= S mod 11;
Result:= NewID + A;
end;
end;