怎样将string转化为pwidechar,怎样给pwidechar分配空间,怎样删除pwidechar所占用的空间? 乱写的,呵呵var S: string P: PWideChar;begin S := 'Hello world'; P := PWideChar(PChar(S));end; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 var S:string; P:pwidechar;beginS:='hello world';copymemory(P,@string[1],length(string));end; pName,pPassWord,pGroup,pMemo:PWideChar;beginResult:='其它错误';getmem(pName,1024);getmem(pPassWord,1024);getmem(pMemo,1024);StringToWideChar(name,pname,1024);StringToWideChar(Password,pPassWord,1024);StringToWideChar(Memo,pMemo,1024);//我写的一段程序。正确运行通过。 freemem(parm_err,1024);freemem(pName,1024);freemem(pPassWord,1024);freemem(pMemo,1024);//删除pwidechar所占用的空间? var s,s1: string; pw: PWideChar;begin s:='hello world'; GetMem(pw,2*length(s)+2); pw:=StringToWideChar(s,pw,length(s)+2); s1:=WideCharToString(pw); edit1.Text:=s1; freemem(pw);end; 我在用API碰到PCHAR类型时,如直接定义其类型,往往会出错。我的解决办法是:定义CHAR类型的数组,你不妨可以一试。 标准做法:var s:sting; pwc:PWidechar; len:integer;begin s:='abcdefg'; len:=length(s)+1; pwc:=AllocMem(len*sizeof(widechar)); stringtowidechar(s,pwc,len); showmessage(widechartostring(pwc)); FreeMem(pwc);end; 大家对STRINGTOWIDECHAR函数有理解上的错误。STRINGTOWIDECHAR(S,PW,此处应为PW的空间大小除以2:也就是length(s)+1。) 不好意思,我试了各位的答案,都是正确的,只好分别给点分了,谢谢大家帮助,另外,可不可以帮我看看http://www.csdn.net/expert/topic/195/195718.shtm,再次谢谢! 如何得到一个flash文件的桢数? Delphi里有几种弹出对话框,带的参数是怎么样的??? 求聘vb或delphi程序员 怎么读出DBGrid中当前选择的记录各字段内容? Delphi里怎么调用vc写的动态连接库? 淘宝DELPHI自动登录代码的问题,高手请进,急!!! FASTREPORT中如何绘出表格 Delphi设置主菜单中菜单项的位置 又一个语法问题。 关于midas服务器的问题 请问如何实现文字控件(例如memo,dbmemo等)中,改变部分文字的颜色等属性? B/S结构用何东东编最快?
S:string;
P:pwidechar;
begin
S:='hello world';
copymemory(P,@string[1],length(string));end;
begin
Result:='其它错误';
getmem(pName,1024);
getmem(pPassWord,1024);
getmem(pMemo,1024);
StringToWideChar(name,pname,1024);
StringToWideChar(Password,pPassWord,1024);
StringToWideChar(Memo,pMemo,1024);
//我写的一段程序。正确运行通过。
freemem(pName,1024);
freemem(pPassWord,1024);
freemem(pMemo,1024);
//删除pwidechar所占用的空间?
s,s1: string;
pw: PWideChar;
begin
s:='hello world';
GetMem(pw,2*length(s)+2);
pw:=StringToWideChar(s,pw,length(s)+2);
s1:=WideCharToString(pw);
edit1.Text:=s1;
freemem(pw);
end;
var
s:sting;
pwc:PWidechar;
len:integer;
begin
s:='abcdefg';
len:=length(s)+1;
pwc:=AllocMem(len*sizeof(widechar));
stringtowidechar(s,pwc,len);
showmessage(widechartostring(pwc));
FreeMem(pwc);
end;
STRINGTOWIDECHAR(S,PW,此处应为PW的空间大小除以2:也就是length(s)+1。)