static void TestCreateProcessAndInjectDll(string cmdLine, string dllName) { DeviareLiteInterop.HookLib.STARTUPINFO si; DeviareLiteInterop.HookLib.ProcessInfo pi; MessageBox.Show("Launching CALC and injecting DLL after startup\r\r(close Calc to next test)", "Dll Inject Test", MessageBoxButtons.OK); try { si = new DeviareLiteInterop.HookLib.STARTUPINFO(); pi = cHook.CreateProcess(cmdLine, "", null, null, false, 0, null, null, si); System.Threading.Thread.Sleep(1000); //sleep for a while in order to let the process initialize properly cHook.InjectDll(pi.procId, dllName); WaitForSingleObject(pi.procHandle.DangerousGetHandle(), 0xFFFFFFFF); } catch (Exception ex) { MessageBox.Show("Couldn't complete operation\r\rError: " + ex.ToString(), "Dll Inject Test", MessageBoxButtons.OK, MessageBoxIcon.Error); } }