[try Beta version]
Not logged in

 
Windows API not working on Win 11

Oct 10, 2022 at 3:08pm
Hello guys,


I recently written code to capture an image doing basically:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "windows.h"

#include "vfw.h"

#include <cstdio>

#pragma comment(lib, "Vfw32.lib")

// ********************************** //
int main()
{

    // create the preview window
    HWND hCam = capCreateCaptureWindow(
            "hoven",
            WS_CHILD,
            0, 0, 0, 0,
            ::GetDesktopWindow(), 0);

    // connect to the first camera
    // for other cameras try index
    // 1, 2, in place of the 0 below
    if(capDriverConnect(hCam, 0))
    {

        capFileSaveDIB(hCam, L"here.bmp");

        // the screenshot is in the current
        // directory, usually the same
        // where the exe is created by
        // your compiler
        printf("Saved as shot.bmp!");

    }

    else
    {

        printf("Check camera?");

    }



    return 0;

}



and it works just fine for windows 10 and lower. But if i try it on Win11, i get "shot.bmp" with 0 Bytes of size. (Ive tested that on multiple Windows 11 devices with webcams, that worked with Win10 already and none of the win11 ones worked)

Does anyone know, whats the problem here?

Thanks

Luke
Oct 10, 2022 at 4:36pm
Tested on my PC with Windows 10 and it does not work.
I have a bmp file with a null size :/

The code which you copy does not work as expected :
https://hoven.in/cpp-graphics/take-webcam-pic.html

For webcam, you should use Escapi - a cool template ++
https://github.com/jarikomppa/escapi
Last edited on Oct 10, 2022 at 5:37pm
Topic archived. No new replies allowed.