none
VS2012 MFC 使用外部OCX提供的API 接口函数需要的参数是LPCTSTR该如何给值? RRS feed

  • 问题

  • 在.h中的外部函数定义是:

    void Run(TCHAR* videoDeviceName, TCHAR* videoDisplayName, unsigned long videoWidth, unsigned long videoHeight, unsigned __int64 videoTimePerFrame, unsigned long videoCropLeft, unsigned long videoCropTop, unsigned long videoCropRight, unsigned long videoCropBottom, long videoCodec, long rc, unsigned long videoBitrate, unsigned long qp, long gop, TCHAR* audioDeviceName, TCHAR* audioDisplayName, unsigned long audioChannel, unsigned long audioRate, unsigned long audioBitrate, unsigned long showPropertyPage, long physconType, long tvStandard)
    	{
    		static BYTE parms[] = VTS_BSTR VTS_BSTR VTS_UI4 VTS_UI4 VTS_UI8 VTS_UI4 VTS_UI4 VTS_UI4 VTS_UI4 VTS_I4 VTS_I4 VTS_UI4 VTS_UI4 VTS_I4 VTS_BSTR VTS_BSTR VTS_UI4 VTS_UI4 VTS_UI4 VTS_UI4 VTS_I4 VTS_I4 ;
    		InvokeHelper(0x2, DISPATCH_METHOD, VT_EMPTY, NULL, parms, videoDeviceName, videoDisplayName, videoWidth, videoHeight, videoTimePerFrame, videoCropLeft, videoCropTop, videoCropRight, videoCropBottom, videoCodec, rc, videoBitrate, qp, gop, audioDeviceName, audioDisplayName, audioChannel, audioRate, audioBitrate, showPropertyPage, physconType, tvStandard);
    		
    	}

    0我的调用函数是

    	CString videodevicename  =L"None"; 
    	CString videodisplayname =L"None"; 
    	CString audiodevicename  =L"None"; 
    	CString audiodisplayname =L"None"; 
    
    unsigned long videowidth=640,videoheight=480,left=0,top=0,right=0,bottom=0,videobitrate=1024,qp=35,audiochannel=2,audiorate=44100,audiobitrate=128,showpropertypage=0;
    	unsigned long long timeperframe=400000;
    Run(
    		videodevicename,videodisplayname,videowidth,videoheight,
    		//NULL,NULL,videowidth,videoheight,
    		timeperframe,left,top,right,bottom,
    		GMedia.GOCX_GMediaCodecType_X264,GMedia.GOCX_CodeRateControl_CBR,videobitrate,qp,
    		GMedia.GOCX_GopPicSizeValue_4,audiodevicename,audiodisplayname,
    		audiochannel,audiorate,audiobitrate,showpropertypage,
    		GMedia.GOCX_VideoPhysConnType_Default,GMedia.GOCX_TVAnalogVideo_None
    		);

    vs2012字符集是UNICODE可以确定问题是出在

    videodevicename,videodisplayname,audiodevicename,audiodisplayname,

    它们上面,请问我该怎么做?

    非常急!在线等!谢谢各位了

    2014年11月11日 9:06

全部回复

  • 你好:

          应该是传入的参数类型不对的原因,你可以先将CString转化为THAR* 类型在传入函数。参考这个函数CString::GetBuffer http://msdn.microsoft.com/en-us/library/aa314880%28v=vs.60%29.aspx

    网上也好很多这样的例子,例如: http://blog.csdn.net/guaren0118/article/details/7758091 希望这对你有帮助。

    Shu Hu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年11月12日 1:41
  • 你好!发现和参数CString videodevicename  =L"None";
    CString videodisplayname =L"None";
    CString audiodevicename  =L"None";
    CString audiodisplayname =L"None";

    它们的长度有关系使用短的传递过去就成功了要是CString audiodisplayname = L"@device:cm:{33D9A762-90C8-11D0-BD43-00A0C911CE86}\\wave:{219337E6-F7AD-4BA8-9B17-31C4401F0BDF}";

    这样的参数就会弹出无效的参数数目提示窗口。

    2014年11月18日 2:39