标签:
;为了省事把所有变量都global了;demageFileFun.ahkdemageFile(fileName) {globalopenFile(fileName)writeFileTimes()file.close()}openFile(filename){globalfile := FileOpen(filename,"rw")FileGetSize,size,%filename%LOOPTIMES := round(RATE * size);writeChar一个字节写入一次,所以多少个字节循环多少次;}writeFileTimes(){globalwirteFile(0);文件的开头,中间,结尾都损坏;wirteFile(round(size * 0.5))wirteFile(round(size * (1- RATE )))}wirteFile(pos) {;把文件指定位置的后面部分损坏掉;globalfile.seek(pos)loop,%LOOPTIMES%{Random, rand , 0, 127file.Writechar(rand) ;writeChar一次写入一个字节;参数rand是整数也行;}}^escape::exitapp
;2015-12-31 星期四 12:04;demageFile-手动选择.ahk#NoTrayIcon#singleinstance forceif 1={FileSelectFile, deFileif 1=exitapp,0} else {;可以把文件拖放到图标上的方式来传递参数deFile =%1%}RATE := 0.2try {demageFile(deFile)msgbox 损坏成功exitapp,0} catch e {msgbox 损坏失败msgbox %e%exitapp,1} finally {file.close()}return#include demageFileFun.ahk
;2015-12-31 星期四 12:04;demageFile.ahk#NoTrayIcon#singleinstance forceif 1={msgbox 必须传入参数:文件名exitapp,1}deFile =%1%RATE := 0.2;一次损坏文件的比率try {demageFile(deFile) ;这里用%1%会出错...exitapp,0} catch e {msgbox %e%exitapp,1} finally {file.close()}return#include demageFileFun.ahk
- 使用说明:
注意:一旦损坏,数据无法恢复;请谨慎使用!!
标签:
原文地址:http://www.cnblogs.com/QIAOXINGXING001/p/5114334.html