Hyluss

[Prir] Przykład dziedziczenia uchwytu pliku – pr macierzysty

Oct 10th, 2017
565
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <Windows.h>
  3. #include <WinBase.h>
  4. #include <iostream>
  5. #include <sstream>
  6. #include <conio.h>
  7.  
  8. using namespace std;
  9.  
  10.  
  11. int _tmain(int argc, _TCHAR* argv[])
  12. {
  13.     STARTUPINFO si;
  14.     PROCESS_INFORMATION pi;
  15.     SECURITY_ATTRIBUTES sap;
  16.     HANDLE hwnd;
  17.     stringstream linia;
  18.  
  19.     memset(&sap, 0, sizeof(sap));
  20.     sap.nLength = sizeof(sap);
  21.     sap.bInheritHandle = true;
  22.     hwnd = CreateFile ((LPCWSTR)"wyjscie.txt",FILE_ALL_ACCESS, 0 , &sap, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  23.     memset(&si,0,sizeof(si));
  24.     si.cb = sizeof(si);
  25.  
  26.     linia << " procespotomny.exe " << (DWORD) hwnd;
  27.     CreateProcess ( NULL, (LPWSTR)linia.str().c_str(),
  28.         NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi);
  29.     WaitForSingleObject(hwnd,INFINITE);
  30.     //zamkniecie uchwytow (procesu, wayku, pliku)
  31.     _getch();
  32.  
  33.     return 0;
  34. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment