Groky,这是一个好的开始...感谢您开始。我尝试将其连接起来,但得到了 NotSupportedException。
我已经粘贴了下面我的测试应用程序中的文本。请注意,我尝试使用 [StructLayout(LayoutKind.Sequential)] 装饰结构。我还公开了所有成员,以消除对象可访问性的任何问题。
public partial class Form1 : Form
{
[DllImport("aygshell.dll")]
static extern int SHCameraCapture(ref SHCAMERACAPTURE pshcc);
[StructLayout(LayoutKind.Sequential)]
struct SHCAMERACAPTURE
{
public Int32 cbSize;
public IntPtr hwndOwner;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szFile;
[MarshalAs(UnmanagedType.LPStr)]
public string pszInitialDir;
[MarshalAs(UnmanagedType.LPStr)]
public string pszDefaultFileName;
[MarshalAs(UnmanagedType.LPStr)]
public string pszTitle;
public Int32 StillQuality;
public Int32 VideoTypes;
public Int32 nResolutionWidth;
public Int32 nResolutionHeight;
public Int32 nVideoTimeLimit;
public Int32 Mode;
}
private void ShowCamera()
{
SHCAMERACAPTURE captureData = new SHCAMERACAPTURE
{
cbSize = sizeof (Int64),
hwndOwner = (IntPtr)0,
szFile = "\\My Documents",
pszDefaultFileName = "picture.jpg",
pszTitle = "Camera Demo",
StillQuality = 0,
VideoTypes = 1,
nResolutionWidth = 480,
nResolutionHeight = 640,
nVideoTimeLimit = 0,
Mode = 0
};
SHCameraCapture(ref captureData);
}
private void button1_Click(object sender, EventArgs e)
{
ShowCamera();
}