The code is not original. Write it down first:
1. play audio and video (passed in vc6)
# Include <windows. h> # include <stdio. h> # include <mmsystem. h> # include <shellapi. h> # include <afxcom_.h> # pragma comment (Lib, "winmm. lib ") void main () {char STR [128] = {0}; int I = 0; char Buf [128] = {0}; mci_open_parms mciopen; mcierror; mciopen. lpstrdevicetype = "mpegvideo"; mciopen. lpstrelementname = "G :\\ my videos \ MV \ avril_lavigne _-_ girlfriend _ (palladia) (1080 p )-. MPG "; // callback. Of course, you can change the path here to mcierror = mcisendcommand (0, mci_open, mci_open_type | mci_open_element, (DWORD) & mciopen); If (mcierror) {mcigeterrorstring (mcierror, Buf, 128); printf ("% s \ n", Buf); System ("pause");} uint DeviceID = mciopen. wdeviceid; optional mciplay; mcierror = mcisendcommand (DeviceID, mci_play, 0, (DWORD) & mciplay); If (mcierror) {printf ("Send mci_play command failed \ n "); system ("pause") ;}for (I = 1; I <= 500; I ++) {sleep (500); printf ("% d ", I );}}
After you understand it, you may think it is a minor skill. Studing !!!
2. count the number of lines of code in the folder (passed under vc6)
/* Folder traversal under Win32 is reproduced in callback function (lpctstr lpszpath) {start to find if (no file found) return; do {If (directory found) function (directory found) else statistics on files} while (find the next file and succeeded)} API functions and structures used: findfirstfilefindnextfiletypedef struct _ win32_find_data {DWORD dwfileattributes; // File Attribute filetime ftcreationtime; // File Creation Time: filetime ftlastaccesstime; // file last access time: filetime ftlastwritetime; // last File Modification Time DWORD nfilesizehigh; // file length 32-bit DWORD nfilesizelow; // file length 32-bit DWORD dwreserved0; // The system retains DWORD dwreserved1; // The system retains tchar cfilename [max_path]; // long file name tchar calternatefilename [14]; // optional file name} win32_find_data; */# include <windows. h> # include <stdio. h> # include <string. h> void findallfile (maid); int row, file; int main (INT argc, char ** argv) {maid Path = "E: \ computer programming \ OJ "; ROW = 0; File = 0; findallfile (PATH); printf ("\ n"); printf ("% d C/C ++ source files in total, % d line code \ n", file, row); Return 0;} void findallfile (lpctstr lpszpath) {tchar szfind [max_path]; lstrcpy (szfind, lpszpath); lstrcat (szfind ,"\\*. * "); win32_find_data WFD; handle hfind = findfirstfile (szfind, & WFD); If (hfind = invalid_handle_value) return; do {// if you are not in the root directory, you will see ". "and"... "These two directories -- they are not visible in the resource manager. // The next dos vertex represents the current directory, and the two vertices represent the upper-level directory. If the current folder and the top-level folder are found, ignore them. If (WFD. cfilename [0] = '. ') continue; If (WFD. dwfileattributes & file_attribute_directory) {tchar szfile [max_path]; wsprintf (szfile, "% s \ % s", lpszpath, WFD. cfilename); findallfile (szfile);} else {tchar szfile [max_path]; wsprintf (szfile, "% s \ % s", lpszpath, WFD. cfilename); file * FP; If (FP = fopen (szfile, "R") = NULL) {printf ("failed to open a file! \ N ");} else {int Len = strlen (WFD. cfilename); If (WFD. cfilename [len-1] = 'C' & WFD. cfilename [len-2] = '. '| WFD. cfilename [len-1] = 'P' & WFD. cfilename [len-2] = 'P' & WFD. cfilename [len-3] = 'C' & WFD. cfilename [len-4] = '. ') {file ++; printf ("% s \ n", lpszpath, WFD. cfilename); char data [1000]; while (fgets (data, 1000, FP )! = NULL) Row ++ ;}} fclose (FP) ;}} while (findnextfile (hfind, & WFD); findclose (hfind );}