Using the shcameracapture interface, you can call up a camera to take photos and take photos, and obtain the path of an image or video file.
Run the following code to take a photo:
Shcameracapture SHCC;
Zeromemory (& SHCC, sizeof (SHCC ));
SHCC. cbsize = sizeof (SHCC );
SHCC. hwndowner = NULL;
SHCC. pszinitialdir = NULL;
SHCC. pszdefaultfilename = NULL;
SHCC. psztitle = NULL;
SHCC. stillquality = cameracapture_stillquality_default;
SHCC. videotypes = cameracapture_videotype_all;
SHCC. nresolutionwidth = 0;
SHCC. nresolutionheight = 0;
SHCC. includeotimelimit = 0;
SHCC. mode = cameracapture_mode_still;
Hresult hreturn = shcameracapture (& SHCC );
If hreturn is s_ OK, the image is taken successfully, and SHCC. szfile is the file name (including path ). SHCC. pszinitialdir and SHCC. pszdefafilfilename can be used to set the storage path and default file name. SHCC. hwndowner may be faulty if different forms are used.
Some parameters need to be adjusted for camera recording, as shown below:
SHCC. stillquality = cameracapture_stillquality_normal;
SHCC. videotypes = cameracapture_videotype_standard;
SHCC. nresolutionwidth = 640;
SHCC. nresolutionheight = 480;
SHCC. mode = cameracapture_mode_videowithaudio;
These parameters involve several enumerated variables. Let's take a look:
Typedef Enum {
Cameracapture_mode_still = 0,
Cameracapture_mode_videoonly,
Cameracapture_mode_videowithaudio,
} Cameracapture_mode;
Cameracapture_mode_still corresponds to the photo. cameracapture_mode_videoonly corresponds to the silent video and cameracapture_mode_videowithaudio corresponds to the audio video.
Typedef Enum {
Cameracapture_stillquality_default = 0,
Cameracapture_stillquality_low,
Cameracapture_stillquality_normal,
Cameracapture_stillquality_high,
} Cameracapture_stillquality;
The corresponding image and video definition.
Typedef Enum {
Cameracapture_videotype_all = 0 xFFFF,
Cameracapture_videotype_standard = 1,
Cameracapture_videotype_messaging = 2,
} Cameracapture_videotypes;
Cameracapture_videotype_all corresponds to the photo. cameracapture_videotype_standard corresponds to the WMV Video and cameracapture_videotype_messaging corresponds to the MMS video. When the last two values are used, the nresolutionwidth and nresolutionheight of SHCC cannot be zero. It is generally 640x480.
Unfortunately, this interface can only be used at wm5.0 or above. There is no uniform camera standards in wm2003. hardware vendors can only ask the hardware vendor for calling methods.