📄 define.pas
字号:
TIdSector = packed record
wGenConfig : Word;
wNumCyls : Word;
wReserved : Word;
wNumHeads : Word;
wBytesPerTrack : Word;
wBytesPerSector : Word;
wSectorsPerTrack : Word;
wVendorUnique : Array[0..2] of Word;
sSerialNumber : Array[0..19] of CHAR;
wBufferType : Word;
wBufferSize : Word;
wECCSize : Word;
sFirmwareRev : Array[0..7] of Char;
sModelNumber : Array[0..39] of Char;
wMoreVendorUnique : Word;
wDoubleWordIO : Word;
wCapabilities : Word;
wReserved1 : Word;
wPIOTiming : Word;
wDMATiming : Word;
wBS : Word;
wNumCurrentCyls : Word;
wNumCurrentHeads : Word;
wNumCurrentSectorsPerTrack : Word;
ulCurrentSectorCapacity : DWORD;
wMultSectorStuff : Word;
ulTotalAddressableSectors : DWORD;
wSingleWordDMA : Word;
wMultiWordDMA : Word;
bReserved : Array[0..127] of BYTE;
end;
PIdSector = ^TIdSector;
TDriverStatus = packed record
// 驱动器返回的错误代码,无错则返回0
bDriverError : Byte;
// IDE出错寄存器的内容,只有当bDriverError 为 SMART_IDE_ERROR 时有效
bIDEStatus : Byte;
bReserved : Array[0..1] of Byte;
dwReserved : Array[0..1] of DWORD;
end;
TSendCmdOutParams = packed record
// bBuffer的大小
cBufferSize : DWORD;
// 驱动器状态
DriverStatus : TDriverStatus;
// 用于保存从驱动器读出的数据的缓冲区,实际长度由cBufferSize决定
bBuffer : Array[0..0] of BYTE;
end;
var hDevice : THandle;
cbBytesReturned : DWORD;
// ptr : PChar;
SCIP : TSendCmdInParams;
aIdOutCmd : Array [0..(SizeOf(TSendCmdOutParams)+IDENTIFY_BUFFER_SIZE-1)-1] of Byte;
IdOutCmd : TSendCmdOutParams absolute aIdOutCmd;
procedure ChangeByteOrder( var Data; Size : Integer );
var ptr : PChar;
i : Integer;
c : Char;
begin
ptr := @Data;
for i := 0 to (Size shr 1)-1 do begin
c := ptr^;
ptr^ := (ptr+1)^;
(ptr+1)^ := c;
Inc(ptr,2);
end;
end;
begin
Result := ''; // 如果出错则返回空串
if SysUtils.Win32Platform=VER_PLATFORM_WIN32_NT then begin// Windows NT, Windows 2000
// 提示! 改变名称可适用于其它驱动器,如第二个驱动器: '\\.\PhysicalDrive1\'
hDevice := CreateFile( '\\.\PhysicalDrive0', GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0 );
end else // Version Windows 95 OSR2, Windows 98
hDevice := CreateFile( '\\.\SMARTVSD', 0, 0, nil, CREATE_NEW, 0, 0 );
if hDevice=INVALID_HANDLE_VALUE then Exit;
try
FillChar(SCIP,SizeOf(TSendCmdInParams)-1,#0);
FillChar(aIdOutCmd,SizeOf(aIdOutCmd),#0);
cbBytesReturned := 0;
// Set up data structures for IDENTIFY command.
with SCIP do begin
cBufferSize := IDENTIFY_BUFFER_SIZE;
// bDriveNumber := 0;
with irDriveRegs do begin
bSectorCountReg := 1;
bSectorNumberReg := 1;
// if Win32Platform=VER_PLATFORM_WIN32_NT then bDriveHeadReg := $A0
// else bDriveHeadReg := $A0 or ((bDriveNum and 1) shl 4);
bDriveHeadReg := $A0;
bCommandReg := $EC;
end;
end;
if not DeviceIoControl( hDevice, $0007c088, @SCIP, SizeOf(TSendCmdInParams)-1,
@aIdOutCmd, SizeOf(aIdOutCmd), cbBytesReturned, nil ) then Exit;
finally
CloseHandle(hDevice);
end;
with PIdSector(@IdOutCmd.bBuffer)^ do begin
ChangeByteOrder( sSerialNumber, SizeOf(sSerialNumber) );
(PChar(@sSerialNumber)+SizeOf(sSerialNumber))^ := #0;
Result := PChar(@sSerialNumber);
end;
end;
function str_md5(input1,input2:string):string;
var
Md5_Dig: MD5Digest;
MD5_Con: MD5Context;
Md5UpLen: Integer;
org_str:array [0..35] of char;
begin
strpcopy(org_str,input1);
Md5UpLen := Length(input1);
MD5Init( MD5_Con );
MD5Update( MD5_Con,org_str,Md5UpLen );
MD5Final( MD5_Con,Md5_Dig);
result:=MD5Print(Md5_Dig);
end;
function zc(input1,input2,input3,input4:string):boolean;
begin
result:=false;
if str_md5(input1,'xuyongcz')=input2 then
if is_int(input3)and is_int(input4) then
if strtoint(input3) mod 7 = strtoint(input4) then
if strtoint(input3)>910 then
result:=true;
end;
function push_head_change(csca_mobile,Mobile:string):string ;
var m_len:integer;
begin
Mobile:=SMS_Mobile_change(Mobile);
m_len:=length(Mobile);
if length(trim(csca_mobile))>13 then
csca_mobile:=rightstr(csca_mobile,13); //除去+
if (m_len=12)and (leftstr(Mobile,2)='31')then
begin
Mobile:='9168'+Mobile;
m_len:=m_len+2;
end
else
Mobile:='81'+Mobile;
if AnsiContainsStr(Mobile,'F') then
m_len:=m_len-1;
if length(trim(csca_mobile))<>13 then
result:='001100'+format('%2.2X',[m_len])+Mobile
else
result:='0891'+SMS_Mobile_change(csca_mobile)+'5100'+format('%2.2X',[m_len])+Mobile;
//result:='0051000B81'+b;
end;
function SMS_head_change(csca_mobile,Mobile:string):string ;
var m_len:integer;
begin
Mobile:=SMS_Mobile_change(Mobile);
m_len:=length(Mobile);
if length(trim(csca_mobile))>13 then
csca_mobile:=rightstr(csca_mobile,13); //除去+
if (m_len=12)and (leftstr(Mobile,2)='31')then
begin
Mobile:='9168'+Mobile;
m_len:=m_len+2;
end
else
Mobile:='81'+Mobile;
if AnsiContainsStr(Mobile,'F') then
m_len:=m_len-1;
if length(trim(csca_mobile))<>13 then
result:='001100'+format('%2.2X',[m_len])+Mobile
else
result:='0891'+SMS_Mobile_change(csca_mobile)+'1100'+format('%2.2X',[m_len])+Mobile;
end;
function SMS_body_change(sms_content:string;changed:boolean):string ;
var content,AToText:string;
i,pos_int,len_int:integer;
begin
content:=GBToUcs2(sms_content);
if changed then
begin
for i:=0 to ((length(content) div 8)-1) do
begin
AToText:=RandomFromstr(srtpud);
pos_int:=pos('00240024',content);
len_int:=8;
if pos_int>0 then
content:=replacing(content,AToText,pos_int,len_int);
end;
end;
result:='000800'+inttohex((length(content) div 2),2)+content;
end;
function read_sms_cmgl(sms_content:string;var read_sms_id_fun:tstringlist):string;
var read_sms_temp:Tstringlist;
i:integer;
read_sms_tem:string;
begin
read_sms_temp:=TStringList.Create;
read_sms_temp.DelimitedText:=sms_content;
i:=0;
while i<read_sms_temp.count-5 do
begin
if is_int(read_sms_temp.Strings[i]) then read_sms_id_fun.add(read_sms_temp.Strings[i]) ;
if length(read_sms_temp.Strings[4+i])=(strtoint(read_sms_temp.Strings[3+i])*2+18) then
read_sms_tem:=read_sms_tem+read_sms_temp.Strings[i]+','+SMS_change_back(read_sms_temp.Strings[4+i])+#13#10;
inc(i,6);
end;
read_sms_temp.Clear;
read_sms_temp.Destroy;
result:=read_sms_tem;
end;
function SMS_Mobile_change_back(Mobile:string):string ;
var
m_len,i,j:integer;
output_mobile:string;
begin
m_len:=length(Mobile);
if m_len>0 then
begin
for i:=1 to m_len do
begin
if i mod 2=1 then j:=i+1 else j:=i-1;
output_mobile:=output_mobile+Mobile[j]
end;
if output_mobile[m_len]='F' then
result:=leftstr(output_mobile,m_len-1)
else
result:=output_mobile;
end
else
result:='';
end;
function SMS_change_back(sms_content:string):string;
var smsc_len,send_no_len,sms_len:integer;
smsc_type,sms_type,send_no_type,sms_PID,encode,chinese,chinese_str,sms_len_str:string;
smsc,send_no,datetime,datetimestr:string;
begin
result:='';
smsc_len:=(strtoint(copy(sms_content,1,2)))*2; //长度-1(类型91) *2短信中心实际长度
smsc_type:=(copy(sms_content,3,2));
smsc:=SMS_Mobile_change_back(copy(sms_content,5,(smsc_len-2)));
sms_type:=(copy(sms_content,smsc_len+3,2));
if sms_type='11'then
begin //发送的信息 ,要多加2位,接收中没有00,
//00省 消息基准值(TP-MR) 0 接收的短消息中没有一项(05)
send_no_len:=(strtoint(format('%d',[strtoint('$'+copy(sms_content,smsc_len+7,2))])));
if send_no_len mod 2=1 then send_no_len:=send_no_len+1; //F问题
send_no_type:=(copy(sms_content,smsc_len+9,2));
send_no:=SMS_Mobile_change_back(copy(sms_content,smsc_len+11,send_no_len));
sms_PID:=(copy(sms_content,smsc_len+send_no_len+11,2));
encode:=(copy(sms_content,smsc_len+send_no_len+13,2));
//有效期省
datetime:=(copy(sms_content,smsc_len+send_no_len+15,2));
datetimestr:='未发送的信息';
sms_len_str:=trim(copy(sms_content,smsc_len+send_no_len+17,2));
sms_len:=(strtoint(format('%d',[strtoint('$'+sms_len_str)])))*2;
chinese:=trim(copy(sms_content,smsc_len+send_no_len+19,sms_len));
end
else
begin
send_no_len:=(strtoint(format('%d',[strtoint('$'+copy(sms_content,smsc_len+5,2))])));
if send_no_len mod 2=1 then send_no_len:=send_no_len+1; //F问题
send_no_type:=(copy(sms_content,smsc_len+7,2));
send_no:=SMS_Mobile_change_back(copy(sms_content,smsc_len+9,send_no_len));
sms_PID:=(copy(sms_content,smsc_len+send_no_len+9,2));
encode:=(copy(sms_content,smsc_len+send_no_len+11,2));
datetime:=SMS_Mobile_change_back(copy(sms_content,smsc_len+send_no_len+13,14));
if not is_int(datetime) then exit;
datetimestr:=copy(datetime,1,2)+'-'+copy(datetime,3,2)+'-'+copy(datetime,5,2)+' '+copy(datetime,7,2)+':'+copy(datetime,9,2)+':'+copy(datetime,11,2);
sms_len_str:=trim(copy(sms_content,smsc_len+send_no_len+27,2));
sms_len:=(strtoint(format('%d',[strtoint('$'+sms_len_str)])))*2;
chinese:=trim(copy(sms_content,smsc_len+send_no_len+29,sms_len));
end;
if (length(chinese)=sms_len) and (encode='08') then
chinese_str:=Ucs2ToGB(chinese)
else if (length(chinese)=sms_len) and (encode='00') then
chinese_str:=DecodeSMS7Bit(chinese);
result:= send_no+','+smsc+','+datetimestr+','+(chinese_str) ;
end;
function get_file_size(txt_path:string):longint;
var
F: file of Byte;
nSize: Longint;
begin
result:=-1;
If FileExists(txt_path) then
begin
AssignFile(F, txt_path); // 将C:\MyFile.txt文件与F变量建立连接,后面可以使用F变量对文件进行操作。
Reset(F); // 打开文件
result:=FileSize(F); // 获取文件大小。
CloseFile(F); // 关闭文件
end;
end;
//从一个字符串指定位置替换为另一个定子串。
function replacing(AText,AToText:string;pos_int,len_int:integer):string;
begin
{删除source字符串}
delete(AText,pos_int,len_int);
{插入target字符串到S中}
insert(AToText,AText,pos_int);
{返回新串}
replacing:=AText;
result:=AText;
end;
function RandomFromstr(AValues:array of string): string;
begin
Randomize;
result:=RandomFrom(AValues);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -