Code:
#include <windows.h>
//#include <vfw.h>
#define VFWAPI WINAPI
#define WND_ID 5010
typedef HWND (VFWAPI *LDCAPWND)(LPCWSTR,DWORD,int,int,int,int,HWND,int);
typedef HWND (VFWAPI *LDCAP)(HWND,int);
typedef HWND (VFWAPI *LDCAPPRE)(HWND,bool);
extern LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HINSTANCE hInstance = GetModuleHandle(NULL);
//HWND hButtStartCam;
//HWND hButtStopCam;
//HWND hButtGetFrame;
switch (message) /* handle the messages */
{
case WM_CREATE:
{
HWND hwndc;
HMODULE hMod, hVFW;
LDCAPWND _capCreateCaptureWindowW;
LDCAP _capDriverConnect, _capPreviewRate;
LDCAPPRE _capPreview;
hMod = LoadLibrary("AVICAP32.DLL");
hVFW = LoadLibrary("MSVFW32.dll");
if(!hMod || !hVFW){
MessageBox(NULL,"Error - module",NULL,0);
return 1;
}
//Load CreateCaptureWindow
_capCreateCaptureWindowW = (LDCAPWND)GetProcAddress(hMod,"capCreateCaptureWindowW");
//See if CreateCaptureWindow loaded
if(!_capCreateCaptureWindowW){
MessageBox(NULL,"Error - function1",NULL,0);
return 1;
}
//Create capture window
hwndc = _capCreateCaptureWindowW((LPCWSTR) "Capture Window",
WS_CHILD | WS_VISIBLE | SS_SIMPLE,0, 0, 640, 480,HWND_DESKTOP,
(int) 32);
_capDriverConnect = (LDCAP)GetProcAddress(hMod,"capDriverConnect");
if(_capDriverConnect)
_capDriverConnect(hwndc,0);
else MessageBox(NULL,"Error - function2",NULL,0);
_capPreviewRate = (LDCAP)GetProcAddress(hMod,"capPreviewRate");
if(_capPreviewRate)
_capPreviewRate(hwndc,100);
else MessageBox(NULL,"Error - function3",NULL,0);
_capPreview = (LDCAPPRE)GetProcAddress(hMod,"capPreview");
if(_capPreview)
_capPreview(hwndc,TRUE);
else MessageBox(NULL,"Error - function4",NULL,0);
//Free AVICAP32.DLL
FreeLibrary(hMod);
FreeLibrary(hVFW);
//These are the functions that are "undeclared"
//capDriverConnect(hwndc,0);
//capPreviewRate(hwndc,66);
//capPreview(hwndc,TRUE);
}
break;