title: Module not found
body: <p>I've been working on this one quite a bit and haven't gotten any closer to a solution.</p>
  
  <p>I juut dug up my old copy of the WindowsHookLib again - It's available with source at <a href="http://www.codeproject.com/KB/DLL/WindowsHookLib.aspx" rel="noreferrer">http://www.codeproject.com/KB/DLL/WindowsHookLib.aspx</a>. This library allows Global Windows Mouse/Keyboard/Clipboard Hooks, which is very useful.</p>
  
  <p>I'm trying to use the Mouse Hook in here to Capture Mouse-Motion (I could use a Timer that always polls Cursor.Position, but I plan on using more features of WindowsHookLib later).</p>
  
  <p>Code as follows:</p>
  
  <pre><code>MouseHook mh = new MouseHook();
  mh.InstallHook();
  mh.MouseMove += new EventHandler&lt;WindowsHookLib.MouseEventArgs&gt;(mh_MouseMove);
  </code></pre>
  
  <p>But on the call to InstallHook(), I get an Exception: "The specified Module could not be found". Strange. Searching, I found that someone thought this occurs because a DLL is not in a place included in the Windows PATH variable, and because placing it in system32 didn't help I went the whole hog and translated the thing to C# for inclusion directly in my project (I was curious how it works).</p>
  
  <p>However the error was obstinately persistent, so I dug a bit on this, and found the Code in the Library that is responsible: In InstallHook(), we have</p>
  
  <pre><code>IntPtr hinstDLL = Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]);
  this._hMouseHook = UnsafeNativeMethods.SetWindowsHookEx(14, this._mouseProc, hinstDLL, 0);
  if (this._hMouseHook == IntPtr.Zero)
  {
        throw new MouseHookException(new Win32Exception(Marshal.GetLastWin32Error()).Message);
  }
  </code></pre>
  
  <p>And this (after modification and recompile) tells me that what I'm really getting is a Windows error "ERROR_MOD_NOT_FOUND"! Now, Here I'm stumped. Didn't I just compile the Hook Library directly into my project?</p>
  
  <p>(UnsafeMethods.SetWindowsHookEx is just a DllImported Method from user32)</p>
  
  <p>Any Answers, or Prods in the right direction, or any hints, pointers or similar are very much appreciated!</p>