这有一段DELPHI,谁能帮我改为C++???(10分)

K

kmwap

Unregistered / Unconfirmed
GUEST, unregistred user!
var
s,l_Unicode : string;
l_FilePath : widestring;
i : integer;
begin
l_FilePath := 'c:/文档/文件.doc';
for i := 1 to length(l_FilePath) do
begin
l_Unicode := IntToHex(word(l_FilePath), 4);
l_Unicode := chr(strtoint('$' + copy(l_Unicode, 3, 2))) +
chr(strtoint('$' + copy(l_Unicode, 1, 2)));

s:=s+l_Unicode; //添加一个s连接起来
end;

ShowMessage(PWideChar(s)); //看这个是什么
end;
 
就將幾個賦值語句改一下就行了吧。
 
{AnsiString s,s1,s2,l_Unicode;
WideString l_FilePath;
int i;
l_FilePath = "c://文档//文件.doc";
for( i= 1 ; i<=l_FilePath.Length(); i++)
{
l_Unicode = IntToHex(Word(l_FilePath), 4);
Move(l_Unicode[3],s1,2);
Move(l_Unicode[1],s2,2);
l_Unicode = (char)(StrToInt('$' + s1))+
(char)(StrToInt('$' + s2))

s+=l_Unicode; //添加一个s连接起来
}

ShowMessage(PWideChar(s)); //看这个是什么
}
 
顶部