想通过MIB取得本机MAC并显示出来.response:string;
response已经取得的值为#0#0#1#1#0#0#0#0 response=#0#0#1#1#0#0#0#0
或者是#0#3'G楳'#$CB response=#0#3'G楳'#$CB但memo1.lines.add(response);却不能显示出来.
请高手指点.
response已经取得的值为#0#0#1#1#0#0#0#0 response=#0#0#1#1#0#0#0#0
或者是#0#3'G楳'#$CB response=#0#3'G楳'#$CB但memo1.lines.add(response);却不能显示出来.
请高手指点.
response:string;
outs:string;
x:integer;
begin
response:=#0#3'G楳'#$CB; outs:='';
for x:=1 to Length(response) do
outs:= outs+format('%.2x',[Ord(response[x])]); ShowMessage(outs);
end;
那为什么数值#0#3'G楳'#$CB能赋给已经定义为string的response呢?
谢谢!
用下面这个函数可以转:
function StrToHexStr(const S:string;NoBlack:Boolean=False):string;
//字符串转换成16进制字符串
var
I:Integer;
begin
for I:=1 to Length(S) do
begin
if I=1 then
Result:=IntToHex(Ord(S[1]),2)
else begin
if NoBlack then
Result:=Result+IntToHex(Ord(S[I]),2)
else Result:=Result+' '+IntToHex(Ord(S[I]),2);
end;
end;
end;
用法:
memo1.lines.add(StrtoHex(response)); //两个字符之间有个空格
或者
memo1.lines.add(StrtoHex(response,True));//两个字符之间没有空格
mastersky(浪) ( ) 信誉:97 请到此贴取分
http://community.csdn.net/Expert/topic/5339/5339938.xml?temp=.3128931