Untitled
unknown
c_cpp
4 years ago
1.2 kB
8
Indexable
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <conio.h> #include <Windows.h> #include <string.h> void display_usage(void); int main(int argc, char *argv[]) { char lpCommandLine[256]; FILE *fp; STARTUPINFO startInfo; PROCESS_INFORMATION processInfo; ZeroMemory(&startInfo, sizeof(startInfo)); startInfo.cb = sizeof(startInfo); if (argc < 2) { display_usage(); _getch(); exit(1); } if ((fp = fopen(argv[1], "r")) == NULL) { fprintf(stderr, "Error opening file, %s!", argv[1]); _getch(); exit(1); } while (fscanf(fp, "%s", lpCommandLine) != EOF) { if (!CreateProcess(NULL, lpCommandLine, NULL, NULL, FALSE, HIGH_PRIORITY_CLASS | CREATE_NEW_CONSOLE, NULL, NULL,&startInfo, &processInfo)) { fprintf(stderr, "CreateProcess failed on error %d \n", GetLastError()); ExitProcess(1); } CloseHandle(processInfo.hThread); CloseHandle(processInfo.hProcess); } _getch(); fclose(fp); printf("\nDovidenja!!!\n"); return 0; } void display_usage(void) { fprintf(stderr, "\nProper Usage is: "); fprintf(stderr, "\n\nLIST_IT filename.ext\n"); }
Editor is loading...