title: The process ID returned by the CreateProcess function is different from the task manager
body: <pre><code>#include &lt;Windows.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  
  //创建新的控制台
  int main(void)
  {
      BOOL KillProcess();
      int ret = 0;
      STARTUPINFO si;
      PROCESS_INFORMATION pi;
      ZeroMemory(&amp;si, sizeof(si));
      si.cb = sizeof(si);
      si.dwFlags = STARTF_USESHOWWINDOW;
      si.wShowWindow = TRUE;
      ZeroMemory(&amp;pi, sizeof(pi));
      WCHAR commandline[] = L&quot;notepad.exe&quot;;
      //ret = CreateProcess(NULL, commandline, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &amp;si, &amp;pi);
      //WCHAR commandline1[] = L&quot;notepad.exe&quot;;
      //WCHAR commandline2[] = L&quot;calc&quot;;
      ret = CreateProcess(NULL, commandline, NULL, NULL, FALSE, NULL, NULL, NULL, &amp;si, &amp;pi);
      //ret = CreateProcess(commandline1, commandline2, NULL, NULL, FALSE, NULL, NULL, NULL, &amp;si, &amp;pi);
      if (ret)
      {
          CloseHandle(pi.hThread);
          CloseHandle(pi.hProcess);
          printf(&quot;threadid = %d\n&quot;, pi.dwThreadId);
          printf(&quot;processid = %d\n&quot;, pi.dwProcessId);
      }
      else
      {
          printf(&quot;Start successfully\n&quot;);
      }
      KillProcess();
      system(&quot;pause&quot;);
      return 0;
  }
  
  BOOL KillProcess()
  {
      DWORD dwProcessId;
      printf(&quot;\nPlease input the process ID you want to kill: &quot;);
      scanf_s(&quot;%u&quot;, &amp;dwProcessId);
  
      DWORD dwDesiredAccess = PROCESS_TERMINATE;
      BOOL  bInheritHandle = FALSE;
      HANDLE hProcess = OpenProcess(dwDesiredAccess, bInheritHandle, dwProcessId);
      if (hProcess == NULL)
          return FALSE;
      BOOL result = TerminateProcess(hProcess, 0);
      CloseHandle(hProcess);
      if (result)
      {
          printf(&quot;kill process success\n&quot;);
      }
      else
      {
          printf(&quot;kill process failed\n&quot;);
      }
      return result;
  }
  </code></pre>
  <p>After the code is executed, open the calc.exe pi.dwProcessId ,the process ID returned is different from the PID in the task manager，but open it with code notepad.exe normal.I don't know exactly why. I tried many programs, only the PID of Notepad is the same as task manager
  I need help from the big guys. Thank you！</p>