这2天没更新什么Delphi的博客,原因是F41的笔记本换成用Z500的笔记本上写程序 但是Z500的机器有个问题 F1到F12只有按住FN功能才是F1-F12,所以很不好调试,没办法,自己写了一个改键工具,需要的时候把F1-F9换成1-9.
现在的Delphi的方向是,把自己的常用和有用的函数封装成Delphi一个单元,以后方便调用.这2天封装了一个函数,易语言的取硬盘特征字,关键API是DeviceIoControl CreateFileA CloseHandle 部分关键代码如下
if j_stOutBuffer.bIDEDeviceMap>0 then begin j_stInBuffer.cBufferSize:= 512; j_stInBuffer.bSectorCountReg := 1; j_stInBuffer.bSectorNumberReg := 1; j_stInBuffer.bDriveHeadReg := 160; j_stInBuffer.bCommandReg:= j_stOutBuffer.bIDEDeviceMap; if j_stInBuffer.bCommandReg =0 then begin j_stInBuffer.bCommandReg :=161; end; if j_stInBuffer.bCommandReg <>0 then begin j_stInBuffer.bCommandReg :=236; end; myDeviceIoContro2 (j_h, 508040, j_stInBuffer, 32, j_OutBuffer2, 544, j_ls, 0); begin for j_count:=0 to 19 do j_id[0+j_count]:=j_Outbuffer2[36+j_count]; end; begin for j_count:=0 to 7 do j_id1[0+j_count]:=j_Outbuffer2[62+j_count]; end; begin for j_count:=0 to 39 do j_id2[0+j_count]:=j_Outbuffer2[70+j_count]; end; begin j_zoid[2]:=0; j_zoid[3]:=0; j_last1:=0; j_x:=0; for j_count:=0 to 39 do begin j_x:=j_count+1; if j_x mod 2=0 then begin j_zoid[1]:=j_id2[j_count]; asm mov eax,j_zoid mov j_y,eax end; j_last1:=j_last1+j_y; end; if j_x mod 2<>0 then begin j_zoid[0]:=j_id2[j_count]; end; end; end; begin j_zoid[2]:=0; j_zoid[3]:=0; j_x:=0; for j_count:=0 to 7 do begin j_x:=j_count+1; if j_x mod 2=0 then begin j_zoid[1]:=j_id1[j_count]; asm mov eax,j_zoid mov j_y,eax end; j_last1:=j_last1+j_y; end; if j_x mod 2<>0 then begin j_zoid[0]:=j_id1[j_count]; end; end; end; begin j_zoid[2]:=0; j_zoid[3]:=0; j_x:=0; for j_count:=0 to 19 do begin j_x:=j_count+1; if j_x mod 2=0 then begin j_zoid[1]:=j_id[j_count]; asm mov eax,j_zoid mov j_y,eax end; j_last1:=j_last1+j_y; end; if j_x mod 2<>0 then begin j_zoid[0]:=j_id[j_count]; end; end; end; end; j_p:=@j_Outbuffer2; asm pushad xor eax,eax xor ebx,ebx mov eax,j_p add eax,18 mov bx,[eax] mov j_ml,bx add eax,4 mov bx,[eax] mov j_m2,bx add eax,6 mov bx,[eax] mov j_m3,bx add eax,30 mov bx,[eax] mov j_m4,bx popad end; myCloseHandle(j_h);
这里自己自己初步找了一个貌似比较合适自己的Delphi命名规则:(g_ 全局变量前缀,b_ 程序集变量前缀,j_ 局部变量前缀 h表示句柄lp表示指针st表示结构sz表示字符串 dw表示整型 fl表示小数)
命令规则:作用域_形容+名字