我在Win XP + Delphi 6中调试:
使用StringToWideChar这函数时总是提示地址出错:var
  kk: PWideChar;beginStringToWideChar('ccc', kk, 255)end;倒底想把String类型的字符串赋值给PWideChar类型的变量应该怎么做啊?

解决方案 »

  1.   

    kk: PWideChar你要给他分配内存空间啊,例如。
    PWideChar = AllocMem(100*Sizeof(WideChar));
      

  2.   

    var ps:PWideChar;
        s:string;
    begin
      s:='111111';
      GetMem(ps,SizeOf(PWideChar));
      StringToWideChar(s,ps,Length(s)+1);
      ShowMessage(ps);
    end;
      

  3.   

    倒不如这样。。//-------------------------
    var
      kk: PWideChar;
      str:string;
      wstr:widestring;....
      str:='ccc'
      wstr:=str;
      kk:=PWIDECHAR(wstr);
      

  4.   

    var
      wideChars   : array[0..11] of WideChar;
      myString    : String;begin
      // Set up our string
      myString := 'Hello World';  // Copy to a WideChar format in our array
      StringToWideChar(myString, wideChars, 12);  // Show what the copy gave
      ShowMessage(WideCharToString(wideChars));
    end;
      

  5.   

    各位老兄,不要在这里回复了,原贴在这里,问题已经解决,只是没有结罢了。
    http://expert.csdn.net/Expert/topic/2976/2976632.xml?temp=.8321192