Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't believe Windows exposes (via .NET or otherwise) any method of changing a process's parent.</p> <p>As an alternative, you could run a separate process at system startup (via the "SOFTWARE/Microsoft/Windows/CurrentVersion/Run" registry key for example), and have the triggering application (your screen saver) use inter-process communication (SendMessage or the like) to tell the separate process to launch the browser. Then the separate process would be the parent and the browser wouldn't be killed when the screen saver's process tree is killed.</p> <hr> <p>Here's some example code. Note that this doesn't do any error checking, and I haven't tested it in the context of an actual screen saver, but it should give you an idea of what's involved:</p> <p>In the screen saver class:</p> <pre><code>[DllImport("user32.dll", SetLastError = true)] static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] static extern uint RegisterWindowMessage(string lpString); [DllImport("user32.dll")] static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, UIntPtr wParam, IntPtr lParam); private uint message; </code></pre> <p>In the screen saver's initialization code:</p> <pre><code>message = RegisterWindowMessage("LaunchBrowser"); </code></pre> <p>In the screen saver's browser launching code:</p> <pre><code>SendMessage(FindWindow(null, "BrowserLauncher"), message, UIntPtr.Zero, IntPtr.Zero); </code></pre> <p>In the separate process's form class:</p> <pre><code>[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] static extern uint RegisterWindowMessage(string lpString); private uint message; </code></pre> <p>In the separate process's Form_Load code:</p> <pre><code>message = RegisterWindowMessage("LaunchBrowser"); Text = "BrowserLauncher"; </code></pre> <p>And override the separate process's form's WndProc:</p> <pre><code>protected override void WndProc(ref Message m) { if (m.Msg == message) { Process.Start("iexplore.exe", "http://www.google.com"); } base.WndProc(ref m); } </code></pre> <p>(You'll want to make the separate process's form hidden, of course.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload