|
下面是代码部分,是用了avicap32.dll来控制摄象头,我在debug模式下一切没有问题,一但切换到realease模式下,一按启动按钮start就出现"General Protection"的错误,谢谢了
/*---------------------------------------------------------------------------*/
/* 摄像头相关 */
/*---------------------------------------------------------------------------*/
#include "windows.h"
#include <formatio.h>
#include "avicap32.h"
static int panelHandle;
/*---------------------------------------------------------------------------*/
/* Camera 摄像头相关 */
/*---------------------------------------------------------------------------*/
static int handle;
static int result;
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "video.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
int CVICALLBACK start (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int width;
int height;
int top;
int left;
switch (event)
{
case EVENT_COMMIT:
//获得面板句柄
GetPanelAttribute(panelHandle, ATTR_SYSTEM_WINDOW_HANDLE, &handle);
//获得屏幕中图像要显示的位置
GetCtrlAttribute(panelHandle, PANEL_CANVAS, ATTR_LEFT, &left);
GetCtrlAttribute(panelHandle, PANEL_CANVAS, ATTR_TOP, &top);
GetCtrlAttribute(panelHandle, PANEL_CANVAS, ATTR_HEIGHT, &height);
GetCtrlAttribute(panelHandle, PANEL_CANVAS, ATTR_WIDTH, &width);
//打开摄像头
result = capCreateCaptureWindowA("",WS_CHILD | WS_VISIBLE ,left,top,width,height,handle,0);
//设置摄像头函数
SendMessage((HWND)result, WM_CAP_SET_CALLBACK_ERROR, 0, 0);
SendMessage((HWND)result, WM_CAP_SET_CALLBACK_STATUSA, 0, 0);
SendMessage((HWND)result, WM_CAP_DRIVER_CONNECT, 0, 0);
SendMessage((HWND)result, WM_CAP_SET_SCALE, 1, 0);
SendMessage((HWND)result, WM_CAP_SET_PREVIEWRATE, 66, 0);
SendMessage((HWND)result, WM_CAP_SET_OVERLAY, 1, 0);
SendMessage((HWND)result, WM_CAP_SET_PREVIEW, 1, 0);
break;
}
return 0;
} |
|