1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#define _CRT_SECURE_NO_WARNINGS
// uncomment #define to force use of long path
//#define USE_LONG_NAMES
#include <windows.h>
#include <stdio.h>
#include <string.h>
int main()
{
#ifndef USE_LONG_NAMES
char tempPath[MAX_PATH] = "";
GetTempPath(_countof(tempPath), tempPath);
printf("tempPath = %s\n", tempPath);
#else
char shortTempPath[MAX_PATH] = "";
GetTempPath(_countof(shortTempPath), shortTempPath);
printf("shortTempPath = %s\n", shortTempPath);
char tempPath[MAX_PATH] = "";
GetLongPathName(shortTempPath, tempPath, _countof(tempPath));
printf("tempPath = %s\n", tempPath);
#endif
char folderPath[MAX_PATH] = "";
strcpy(folderPath, tempPath);
strcat(folderPath, "~cplusplus");
printf("folderPath = %s\n", folderPath);
char cmdLine0[1024] = "";
sprintf(cmdLine0, "mkdir \"%s\" 2> nul", folderPath);
printf("cmdLine0 = %s\n", cmdLine0);
system(cmdLine0);
char filePath1[MAX_PATH] = "";
strcpy(filePath1, folderPath);
strcat(filePath1, "\\dir.txt");
printf("filePath1 = %s\n", filePath1);
char cmdLine1[1024] = "";
sprintf(cmdLine1, "dir /b > \"%s\"", filePath1);
printf("cmdLine1 = %s\n", cmdLine1);
system(cmdLine1);
char filePath2[MAX_PATH] = "";
strcpy(filePath2, folderPath);
strcat(filePath2, "\\find.txt");
printf("filePath2 = %s\n", filePath2);
char cmdLine2[1024] = "";
sprintf(cmdLine2, "findstr .cpp \"%s\" > \"%s\"", filePath1, filePath2);
printf("cmdLine2 = %s\n", cmdLine2);
system(cmdLine2);
char cmdLine3[1024] = "";
sprintf(cmdLine3, "notepad.exe \"%s\"", filePath2);
printf("cmdLine3 = %s\n", cmdLine3);
system(cmdLine3);
return 0;
}
|