[DllImport("user32.dll")]
public static extern int FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
Like this. I need both 'em. if I go for intptr, it cant be converted to int propely so postmessage etc stuff fails, other way, stuff that requires "handle" fails because its supposed to be pointer.
Bitmap thisScreenshot = new Bitmap(Width, Height);
Graphics gfxScreenshot = Graphics.FromImage(thisScreenshot);
IntPtr hdcBitmap = gfxScreenshot.GetHdc();
PrintWindow(handle, hdcBitmap, 0);
gfxScreenshot.ReleaseHdc(hdcBitmap);
I basically want to execute this while also having my int findwindow function. any ideas how ? also Findwindow IS the handle, right ?
It is never correct to use the version that returns int. FindWindow returns a window handle, it is always IntPtr. You'll need to fix your PostMessage declaration instead:
[DllImport("user32.dll")]
public static extern bool PostMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);