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;
}
| |