Source.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include <stdlib.h>
  5. #include <math.h>
  6. #include <windows.h>
  7. #define INPUTPATH "D:\\Bolshakov41p\\Processes\\Files\\Input.txt"
  8. #define PATHDOTHA "D:\\Bolshakov41p\\Processes\\x64\\Debug\\Processes.exe"
  9. int main()
  10. {
  11. HANDLE InputFile;
  12. InputFile = CreateFileA(INPUTPATH,
  13. GENERIC_READ,
  14. 0,
  15. NULL,
  16. OPEN_EXISTING,
  17. FILE_ATTRIBUTE_NORMAL,
  18. NULL);
  19. int n;
  20. double a, b, c;
  21. char buffer[256];
  22. ReadFile(InputFile, buffer, 256, &n, NULL);
  23. CloseHandle(InputFile);
  24. sscanf(buffer, "%lf %lf %lf", &a, &b, &c);
  25. char cmdArgs[200];
  26. snprintf(cmdArgs, sizeof(cmdArgs),"%lf %lf %lf",a, b, c);
  27. STARTUPINFO si;
  28. PROCESS_INFORMATION pi;
  29. ZeroMemory(&si, sizeof(si));
  30. si.cb = sizeof(si);
  31. ZeroMemory(&pi, sizeof(pi));
  32. if(!CreateProcessA("D:\\Bolshakov41p\\Processes\\x64\\Debug\\Processes.exe",
  33. cmdArgs,
  34. NULL,
  35. NULL,
  36. TRUE,
  37. 0,
  38. NULL,
  39. NULL,
  40. &si,
  41. &pi))
  42. {
  43. printf("Íå óäàëîñü ñîçäàòü ïðîöåññ. Êîä îøèáêè: %d.\n", GetLastError());
  44. }
  45. WaitForSingleObject(pi.hProcess, INFINITE);
  46. DWORD childExitCode;
  47. GetExitCodeProcess(pi.hProcess, &childExitCode);
  48. CloseHandle(pi.hProcess);
  49. CloseHandle(pi.hThread);
  50. }