This code has worked for me before using Win11!!!
Snippet shows that I'm using Avicap32. I can run the simple .exe app on Win 8 and Win 10 and it works fine, showing my handsome face from the laptop camera in the picture box control on the form. (green active light is lit)
Any ideas why I just get a black picture now?
C#. .Net v4.8, VS 2022 v17.3.4
public void Attach(System.Windows.Forms.PictureBox control)
{
deviceHandle = Avicap32.capCreateCaptureWindow("", Constants.WS_VISIBLE | Constants.WS_CHILD,
0, 0, 0, 0,
control.Handle, 1);
if (User32.SendMessage(deviceHandle, Constants.WM_CAP_DRIVER_CONNECT, (IntPtr)deviceNumber, (IntPtr)0).ToInt32() > 0)
{
User32.SendMessage(deviceHandle, Constants.WM_CAP_SET_PREVIEWRATE, (IntPtr)66, (IntPtr)0);
User32.SendMessage(deviceHandle, Constants.WM_CAP_SET_SCALE, (IntPtr)(-1), (IntPtr)0);
User32.SendMessage(deviceHandle, Constants.WM_CAP_SET_PREVIEW, (IntPtr)(-1), (IntPtr)0);
User32.SetWindowPos(deviceHandle, (IntPtr)(0), 0, 0, control.Width, control.Height, 6);
}
}
I'd use DirectShow but I cannot find EXACTLY how to load and install it. I downloaded Win App SDK, but I don't see DS anywhere!
Thanks to all and any help.