
Machine Vision Camera SDK (C) Developer Guide
int nDeviceIndex = 0;
MV_CC_DEVICE_INFO m_stDevInfo = {0};
memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex],
sizeof(MV_CC_DEVICE_INFO));
nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);
if (MV_OK != nRet)
{
printf("error: CreateHandle fail [%x]\n", nRet);
return;
}
//Connect device
unsigned int nAccessMode = MV_ACCESS_Exclusive;
unsigned short nSwitchoverKey = 0;
nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
if (MV_OK != nRet)
{
printf("error: OpenDevice fail [%x]\n", nRet);
return;
}
//...other processing
//Start acquiring images
nRet = MV_CC_StartGrabbing(m_handle);
if (MV_OK != nRet)
{
printf("error: StartGrabbing fail [%x]\n", nRet);
return;
}
//Get console window handle
HMODULE hKernel32 = GetModuleHandle("kernel32");
GetConsoleWindowAPI =
(PROCGETCONSOLEWINDOW)GetProcAddress(hKernel32,"GetConsoleWindow");
HWND hWnd = GetConsoleWindowAPI(); //window handle
//Display images
nRet = MV_CC_Display(m_handle,hWnd);
if (MV_OK != nRet)
{
printf("error: Display fail [%x]\n", nRet);
return;
}
//...other processing
//Stop acquiring images
nRet = MV_CC_StopGrabbing(m_handle);
135



































































































































































































































































































































































































