title: Not able to execute CreateProcessA function within class member function
body: <p>I am developing a code which will execute another exe by using win32 api function CreateProcess.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;windows.h&gt;
  
  using namespace std;
  
  int main()
  {
      STARTUPINFO startupinfo;
      PROCESS_INFORMATION process_information;
      startupinfo.dwFlags = 0x1;
      startupinfo.wShowWindow = 0x0;
      startupinfo.cb = sizeof(startupinfo);
      if (CreateProcessA ("test.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &amp;startupinfo, &amp;process_information))
      {
          cout &lt;&lt; "[+] We have successfully launched the process\n" ;
          cout &lt;&lt; "[+] PID: " &lt;&lt; process_information.dwProcessId;
          WaitForSingleObject(process_information.hProcess, INFINITE);
          CloseHandle(process_information.hProcess);
          CloseHandle(process_information.hThread);
      }
      else {
           cout &lt;&lt; "[-] Error Code: " &lt;&lt; GetLastError();
           Sleep(3000);
      }  
      return 0; 
  }
  </code></pre>
  
  <p>The above code works like a charm, but i want to apply OOP concepts in this project. So i wrote...</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;windows.h&gt;
  
  using namespace std;
  
  class CppDBG
  {
      public:
          void load_exe();
  };
  
  void CppDBG :: load_exe()
  {
      STARTUPINFO startupinfo;
      PROCESS_INFORMATION process_information;
      startupinfo.dwFlags = 0x1;
      startupinfo.wShowWindow = 0x0;
      startupinfo.cb = sizeof(startupinfo);
      if (CreateProcessA ("test.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &amp;startupinfo, &amp;process_information))
      {
          cout &lt;&lt; "[+] We have successfully launched the process\n" ;
          cout &lt;&lt; "[+] PID: " &lt;&lt; process_information.dwProcessId;
          WaitForSingleObject(process_information.hProcess, INFINITE);
          CloseHandle(process_information.hProcess);
          CloseHandle(process_information.hThread);
      }
      else {
           cout &lt;&lt; "[-] Error Code: " &lt;&lt; GetLastError();
           Sleep(3000);
      }   
  }
  
  int main()
  {
      CppDBG dbg;
      dbg.load_exe();
      return 0;
  }
  </code></pre>
  
  <p>the above code compiled correctly but is not running properly.</p>
  
  <p><a href="https://i.stack.imgur.com/XthKX.png" rel="nofollow noreferrer">Error Image</a></p>
  
  <p>What am I missing?</p>