ole string就是WideString,它和string类型可以互换,直接赋值就可以了,不需要什么函数。

解决方案 »

  1.   

    强制转化成PWideChar就可以了,没有任何问题
      

  2.   

    一样的,用PWideChar()强制转换看看。
      

  3.   

    强制转换了可是还是没用!
    不过还要谢谢各位!
    这样吧:我将问题再重新描述一下:
    我的ole String类型的数据是一个数组里的元素,该数组为variant类型。
      

  4.   

    我怀疑这个可能是ByteArray,而不是Ole String。
    如果是Ole String直接赋值就可以。
      

  5.   

    我又试了直接赋值,但是运行报错:
    could not convert variant of type(Array olestr) into type(string)
      

  6.   

    function OlestrToStr(AValue: PWideChar): String;
    var
       wstrTemp: WideString;
    begin
       wstrTemp := AValue;
       result := wstrTemp;
    end;调用时,直接 OlestrToStr(PWideChar(olestrValue));
    试试?
      

  7.   

    function OlestrToStr(AValue: PWideChar): String;
    var
       wstrTemp: WideString;
    begin
       wstrTemp := AValue;
       result := wstrTemp;
    end;调用时,直接 OlestrToStr(PWideChar(olestrValue));
    试试?
      

  8.   

    to  kyee(浪子阿鹏)
    我试了你的方法,可是编译时出现 invalid typecast的提示?
      

  9.   

    OleStrToString copies data from the format used by COM into a Pascal string.Copies data received from a COM interface to a string.
    PWideChar是一个指针类型,可以使用强类型转换