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();
}
흠, 난 내가 설치 한 컴팩트 프레임 워크를 가지고 적이 없다 같은 코드를 시도 할 수 없어요 두려워. 그러나 "\\ My Documents"는 유효한 파일 시스템 경로가 아닌 쉘 폴더입니다. 전체 파일 시스템 경로를 사용해보십시오. (컴 볼트 프레임 워크에서 일이 다르게 작동하지 않는 한 무시하십시오!) – Grokys
@Groky : 틀렸어, 그 길이야. 장치에는 드라이브 문자가 없습니다. – ctacke