AutoRun 免疫程式的編寫

2021-07-09 04:01:26 字數 1304 閱讀 2991

在oninitdialog()中新增:

char szdriverstring[maxbyte] = ;

char *ptmp = null;

setdlgitemtext(idc_combo_driver, _t("請選擇欲免疫的碟符..."));

getlogicaldrivestrings(maxbyte, szdriverstring);

ptmp = szdriverstring;

while(*ptmp)

「免疫」按鈕:

#define autorun "autorun.inf"

//建立無法刪除的目錄

#define immunity "\\immunity...\\"

void cimmunityudlg::onok()

; getdlgitemtext(idc_combo_driver, szpath, max_path);

//建立autorun.in資料夾

strcat(szpath, autorun);

bool bret = createdirectory(szpath, null);

if(!bret)

//建立無法刪除的用來免疫的資料夾

strcat(szpath, immunity);

bret = createdirectory(szpath, null);

if(!bret)

else

afxmessagebox("免疫成功!");

}

「取消」按鈕:

void cimmunityudlg::oncancel() 

;getdlgitemtext(idc_combo_driver, szpath, maxbyte);

strcat(szpath, autorun);

strcat(szpath, immunity);

removedirectory(szpath);

zeromemory(szpath, max_path);

getdlgitemtext(idc_combo_driver, szpath, maxbyte);

strcat(szpath, autorun);

removedirectory(szpath);

afxmessagebox("刪除成功!");

程式的編寫風格

程式設計風格雖然不會影響程式的功能,但會影響可讀性。程式的版式追求清晰 美觀,是程式風格的重要構成因素。空行起著分隔程式段落的作用。空行得體 不能過多也不能過少 將使程式的布局更加清晰。空行不會浪費記憶體,雖然列印含有空行的程式是會多消耗一些紙張,但是值得。所以不要捨不得用空行。在每個類宣告之後 每...

程式編寫風格

1.編寫程式時,可以在運算子的左右或是逗號 之後適當地使用一些空白,讓程式看來不那麼擁擠。對比 int i 0 int i 0 2.在宣告字串並指定字串值時,如果字串長度過長,可以分作兩行來寫,比較容易閱讀,例如 string text n n 3.類名首字母大寫 方法名稱的命名慣例為首字母小寫 名...

編寫網路程式

為什麼需要htons ntohl ntohs htons 函式 2009 12 11 13 15 51 分類 在c c 寫網路程式的時候,往往會遇到位元組的網路順序和主機順序的問題。這是就可能用到htons ntohl ntohs htons 這4個函式。網路位元組順序與本地位元組順序之間的轉換函式...