window API一天一練之操作檔案和目錄

2021-06-19 03:37:41 字數 2479 閱讀 9620

今天花了好長時間了解檔案和目錄相關的api ,寫了簡單的驗證程式,如有問題之處,希望各位大神指正。**比較多久不一一枚舉api的宣告之類的資訊了。

/***********************************

功能:輸出檔案屬性資訊

引數:檔案屬性

*************************************/

void printfileattributemessage(dword dwfileattribute)

else if (dwfileattribute & file_attribute_temporary)

else if (dwfileattribute & file_attribute_offline)

else if (dwfileattribute & file_attribute_not_content_indexed)

else if (dwfileattribute & file_attribute_hidden)

else if (dwfileattribute & file_attribute_system)

else if (dwfileattribute & file_attribute_normal)

else if (dwfileattribute & file_attribute_readonly) }

/***********************************

功能:獲取檔案屬性資訊

引數:*************************************/

void getfileattributeinfo()

printfileattributemessage(dwfileattribute); }

/***********************************

功能:將系統時間轉為中文格式輸出

引數:系統時間

*************************************/

void printfiletime(systemtime &systemtime)

/***********************************

功能:輸出檔案資訊

引數:檔案資訊

*************************************/

void printfileinfo(win32_find_data &findfiledata )

if (filetimetosystemtime(&findfiledata.ftlastaccesstime,&systemtime))

if (filetimetosystemtime(&findfiledata.ftlastwritetime,&systemtime)) }

/***********************************

功能:遍歷檔案目錄並輸出目錄下所有檔案資訊

引數:路徑

*************************************/

void enumeratefile(lpstr lppath)

else

if ((findfiledata.dwfileattributes & file_attribute_directory))

else

}while (findnextfile(hfile,&findfiledata));

}}/***********************************

引數:*************************************/

void menu()

else

}break;

case 2:

else

}break;

case 3:

zeromemory(szpathname,max_path);

if (!getcurrentdirectory(max_path,szpathname))

else

}break;

case 4:

else

}break;

case 5:

;handle hfile;

hfile = findfirstfile(szpathname,&findfiledata);

if (hfile == invalid_handle_value)

else

}findclose(hfile);

}break;

case 6:

break;

case 7:

break;

case 8:

}break;

case 9:

}break;

}printf("請選擇操作項:\n");

scanf("%d",&ioption);

} }}

window API一天一練之共享記憶體

今天學習win下共享記憶體的程序通訊,仿照qt的共享記憶體類,封裝了乙個簡單的類。雖然比不上qt的類那麼完善和強大,但是通過學習也達到了理解win共享記憶體的方式。html class winsharedmemory html winsharedmemory winsharedmemory stri...

SQL一天一練(二)

select prod id,prod name from products where prod name like fish 這條sql語句是找出所有以fish開頭的prod name 那麼如果這樣寫 select prod id,prod name from products where pr...

MFC一天一練 靜態選單操作

直入主題 一 如何給選單增加標記?uint cmenu checkmenuitem uintnidcheckitem,uintncheck 具體使用參考msdn 二 如何設定預設的選單選項?bool cmenu setdefaultitem uintuitem,boolfbypos false 具體...