// using reflection to use an internal .Net method to find the MainWindowHandle public CmdExeApi findHostProcessHandle() { HostHandle = HostCmdExeProcess.MainWindowHandle; if (HostHandle == null || HostHandle.ToInt32() == 0) { "in CmdExeAPI, HostCmdExeProcess.MainWindowHandle was null, so trying to find it using reflection".info(); var processInfo = HostCmdExeProcess.field("processInfo"); if (processInfo == null) { "Process info was null".error(); } else { var processManagerType = "System".type("ProcessManager"); if (processManagerType == null) { "processManagerType was null".error(); } else { HostHandle = (IntPtr)processManagerType.invokeStatic("GetMainWindowHandle", processInfo); } } } if (HostHandle == null || HostHandle.ToInt32() == 0) { "in CmdExeAPI, HostCmdExeProcess.MainWindowHandle, failed to get the MainWindowHandle".error(); } else { "handle:{0}".format(HostHandle.ToInt32()).info(); } return(this); }
public void hostStop() { HostCmdExeProcess.stop(); }