class_docstr: Runs a shell command in a 'with' context.
  
  This implementation is Win32-specific.
  
  Example:
      # Runs the command interactively with default console stdin/stdout
      with ShellCommandController('python -i') as scc:
          scc.run()
  
      # Runs the command using the provided functions for stdin/stdout
      def my_stdout_func(s):
          # print or save the string 's'
          write_to_stdout(s)
      def my_stdin_func():
          # If input is available, return it as a string.
          if input_available():
              return get_input()
          # If no input available, return None after a short delay to
          # keep from blocking.
          else:
              time.sleep(0.01)
              return None
    
      with ShellCommandController('python -i') as scc:
          scc.run(my_stdout_func, my_stdin_func)
code: def __enter__(self):
      cmd = self.cmd
      mergeout = self.mergeout
  
      self.hstdout, self.hstdin, self.hstderr = None, None, None
      self.piProcInfo = None
      try:
          (
              p_hstdout,
              c_hstdout,
              p_hstderr,
              c_hstderr,
              p_hstdin,
              c_hstdin,
          ) = [None] * 6
  
          # SECURITY_ATTRIBUTES with inherit handle set to True
          saAttr = SECURITY_ATTRIBUTES()
          saAttr.nLength = ctypes.sizeof(saAttr)
          saAttr.bInheritHandle = True
          saAttr.lpSecurityDescriptor = None
  
          def create_pipe(uninherit):
              """Creates a Windows pipe, which consists of two handles.
  
              The 'uninherit' parameter controls which handle is not
              inherited by the child process.
              """
              handles = HANDLE(), HANDLE()
              if not CreatePipe(
                  ctypes.byref(handles[0]),
                  ctypes.byref(handles[1]),
                  ctypes.byref(saAttr),
                  0,
              ):
                  raise ctypes.WinError()
              if not SetHandleInformation(
                  handles[uninherit], HANDLE_FLAG_INHERIT, 0
              ):
                  raise ctypes.WinError()
              return handles[0].value, handles[1].value
  
          p_hstdout, c_hstdout = create_pipe(uninherit=0)
          # 'mergeout' signals that stdout and stderr should be merged.
          # We do that by using one pipe for both of them.
          if mergeout:
              c_hstderr = HANDLE()
              if not DuplicateHandle(
                  GetCurrentProcess(),
                  c_hstdout,
                  GetCurrentProcess(),
                  ctypes.byref(c_hstderr),
                  0,
                  True,
                  DUPLICATE_SAME_ACCESS,
              ):
                  raise ctypes.WinError()
          else:
              p_hstderr, c_hstderr = create_pipe(uninherit=0)
          c_hstdin, p_hstdin = create_pipe(uninherit=1)
  
          # Create the process object
          piProcInfo = PROCESS_INFORMATION()
          siStartInfo = STARTUPINFO()
          siStartInfo.cb = ctypes.sizeof(siStartInfo)
          siStartInfo.hStdInput = c_hstdin
          siStartInfo.hStdOutput = c_hstdout
          siStartInfo.hStdError = c_hstderr
          siStartInfo.dwFlags = STARTF_USESTDHANDLES
          dwCreationFlags = (
              CREATE_SUSPENDED | CREATE_NO_WINDOW
          )  # | CREATE_NEW_CONSOLE
  
          if not CreateProcess(
              None,
              "cmd.exe /c " + cmd,
              None,
              None,
              True,
              dwCreationFlags,
              None,
              None,
              ctypes.byref(siStartInfo),
              ctypes.byref(piProcInfo),
          ):
              raise ctypes.WinError()
  
          # Close this process's versions of the child handles
          CloseHandle(c_hstdin)
          c_hstdin = None
          CloseHandle(c_hstdout)
          c_hstdout = None
          if c_hstderr is not None:
              CloseHandle(c_hstderr)
              c_hstderr = None
  
          # Transfer ownership of the parent handles to the object
          self.hstdin = p_hstdin
          p_hstdin = None
          self.hstdout = p_hstdout
          p_hstdout = None
          if not mergeout:
              self.hstderr = p_hstderr
              p_hstderr = None
          self.piProcInfo = piProcInfo
  
      finally:
          if p_hstdin:
              CloseHandle(p_hstdin)
          if c_hstdin:
              CloseHandle(c_hstdin)
          if p_hstdout:
              CloseHandle(p_hstdout)
          if c_hstdout:
              CloseHandle(c_hstdout)
          if p_hstderr:
              CloseHandle(p_hstderr)
          if c_hstderr:
              CloseHandle(c_hstderr)
  
      return self
  
imports: from __future__ import print_function
  import os, sys, threading
  import ctypes, msvcrt
  from .None import py3compat
  from ctypes import POINTER
  from ctypes.wintypes import HANDLE, HLOCAL, LPVOID, WORD, DWORD, BOOL, ULONG, LPCWSTR
label_desc: Use image node_id 2 for calling the Win32ShellCommandController obj's underlying member method code with example usage: obj.__enter__() and returns: self, handles,  handles