请教一下
ES_SetOutputFile(m_hEncoder,pansichar('E:\test.wmv');可以正常运行。

str:='E:\test.wmv';
ES_SetOutputFile(m_hEncoder,pansichar(str);
就不对了呢。

解决方案 »

  1.   

    ES_SetOutputFile 函数原型/声明是怎样?
      

  2.   

    FUNCIMPORT int __stdcall ES_SetOutputFile(HANDLE hEncoder, char* szFileName);
      

  3.   

    ES_SetOutputFile(m_hEncoder,pansichar(str);比较ES_SetOutputFile(m_hEncoder,pansichar(str));
      

  4.   

    然后改成delphi
    function ES_SetOutputFile(hEncoder:THandle;szFileName:Pchar):integer;
      

  5.   

    然后改成delphi
    function ES_SetOutputFile(hEncoder:THandle;szFileName:Pansichar):integer
      

  6.   

    ES_SetOutputFile(m_hEncoder,pchar(str); 这样试试,强制转换
    另外,具体出错提示是什么啊?
      

  7.   

    按理是没问题,要不试试 str: ansistring;
      

  8.   

    关键是楼主用的哪个版本的Delphi,如果是2009、2010以后的版本,String默认是UnicodeString
      

  9.   

    楼主使用的是哪个版本的Delphi。
      

  10.   

    估计是delphi2010的字符串类型兼容问题。试试str: ansistring;吧。
      

  11.   

    str:='E:\test.wmv';
    ES_SetOutputFile(m_hEncoder,pchar(str));
      

  12.   

    str:='E:\test.wmv';
    ES_SetOutputFile(m_hEncoder,pchar(str));
    function ES_SetOutputFile(hEncoder:THandle;szFileName:Pchar):integer;stdcall;
      

  13.   

    Delphi版本常识。其实,将string转换成PChar类型进行读写之后需要进行类型转换的。
    例子:
    procedure SampleProcedure;
    var
      AStr: string;
    begin
      SetLength(AStr, 100);
      CallAPI(XX, PChar(AStr), Length(AStr));
      AStr := PChar(AStr);
      ....
    end;
    这个在Macro的pascal精要中强调过的。
      

  14.   

    str:='E:\test.wmv';
    ES_SetOutputFile(m_hEncoder,pchar(str));
    感觉这个是对的