我在Win XP + Delphi 6中调试:
使用StringToWideChar这函数时总是提示地址出错:var
kk: PWideChar;beginStringToWideChar('ccc', kk, 255)end;倒底想把String类型的字符串赋值给PWideChar类型的变量应该怎么做啊?
使用StringToWideChar这函数时总是提示地址出错:var
kk: PWideChar;beginStringToWideChar('ccc', kk, 255)end;倒底想把String类型的字符串赋值给PWideChar类型的变量应该怎么做啊?
PWideChar = AllocMem(100*Sizeof(WideChar));
s:string;
begin
s:='111111';
GetMem(ps,SizeOf(PWideChar));
StringToWideChar(s,ps,Length(s)+1);
ShowMessage(ps);
end;
var
kk: PWideChar;
str:string;
wstr:widestring;....
str:='ccc'
wstr:=str;
kk:=PWIDECHAR(wstr);
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;
http://expert.csdn.net/Expert/topic/2976/2976632.xml?temp=.8321192