Programmatically capture images with Camera application

While developing an application I found that following methods can be used to launch the Camera capture application.

I have seen the following code work on WM 5.0 device:

SHELLEXECUTEINFO ExecInfo = {0};
ExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ExecInfo.lpFile = L”\\windows\\pimg.exe”;
ExecInfo.lpParameters = L”-camerakey”;
ExecInfo.lpVerb = L”open”;
ShellExecuteEx(&ExecInfo);

And following code on WM 6.0 device:

void ShowCameraCapture()
{

SHCAMERACAPTURE shcc;

// Set the SHCAMERACAPTURE structure.
ZeroMemory(&shcc, sizeof(shcc));
shcc.cbSize = sizeof(shcc);
shcc.hwndOwner = hwndOwner;
shcc.pszInitialDir = NULL;
shcc.pszDefaultFileName = NULL;
shcc.pszTitle = TEXT(“PK Camera”);
shcc.VideoTypes = CAMERACAPTURE_VIDEOTYPE_ALL;
shcc.nResolutionWidth = 0;
shcc.nResolutionHeight = 0;
shcc.nVideoTimeLimit = 0;
shcc.Mode = CAMERACAPTURE_MODE_STILL;

// Launch the Camera Capture screen
SHCameraCapture(&shcc);

}

You can fillup the fields of SHCAMERACAPTURE structure for controlling many aspects of camera operations. Look into MSDN for details.

Leave a Reply