请用delphi写一下怎么实现
解决方案 »
- *** 高分求助,关于IndyHttp提交到Web页面 ***
- 求救:如何动态创建POPUPMENU(弹出菜单);
- access数据库多表查询统计分组的问题
- 请问高手,怎么合计DBGrid某一列的数据,具体怎么写????
- -- 热烈庆祝我与我老婆(女友^^!)见面一周年 -- (斑竹手下留贴,放在这里为的是面熟,结贴时我转走)
- WM_Help消息能被什么钩子捕获?
- 如何进行GSP认证
- 屏幕自动适应问题
- 一个关于用NMSMTP控件发邮件的问题
- 安装控件时总是遇到:“[Fatal Error] DBGridEHold.pas(21): File not found: 'EhGrids.dcu'
- 怎样动态创建按钮?
- 请帮我分析这个软件是如何获取计算机硬盘物理序列号的
我做过一个将文件流转成字串的程序不知你能否用procedure StrToStream(const sIn:string;var sm:TMemoryStream);
var
nTemp,nCount:integer;
nLp:integer;
s1,s2:string;
bTemp:Byte;
begin
if sm=nil then Exit;
if (Length(sIn) mod 2)<>0 then Exit;
nCount:=Round(Length(sIn)/2);
for nLp:=0 to nCount-1 do
begin
bTemp:=0;
s1:=Copy(sIn,nLp*2+1,1);
s2:=Copy(sIn,nLp*2+2,1);
if (s1='') or (s2='') then continue;
if s1='A' then nTemp:=10
else if s1='B' then nTemp:=11
else if s1='C' then nTemp:=12
else if s1='D' then nTemp:=13
else if s1='E' then nTemp:=14
else if s1='F' then nTemp:=15
else nTemp:=StrToInt(s1);
bTemp:=bTemp+nTemp*16;
if s2='A' then nTemp:=10
else if s2='B' then nTemp:=11
else if s2='C' then nTemp:=12
else if s2='D' then nTemp:=13
else if s2='E' then nTemp:=14
else if s2='F' then nTemp:=15
else nTemp:=StrToInt(s2);
bTemp:=bTemp+nTemp;
sm.Position:=sm.Size;
sm.writebuffer(bTemp,1);
end;
sm.Position:=0;
end;function StreamToStr(sm:TMemoryStream):string;
var
nLp:integer;
bTemp:Byte;
begin
result:='';
if sm=nil then Exit;
for nLp:=0 to sm.Size-1 do
begin
sm.Position:=nLp;
sm.Read(bTemp,1);
result:=result+IntToHex(bTemp,2);
end;
end;
Chr(HexToInt('1A'))
AscII to Hex
IntToHex(Ord('A'))
AscII to Hex
IntToHex(Ord('A'),2)
var
i: integer;
begin
for i := 1 to Length(Hex) do
Result := Result + IntToStr(Ord(Hex[i]));
end;function AscToHex(Asc: string): string;
var
B: string[2];
i: integer;
begin
if Length(Asc) mod 2 <> 0 then raise Exception.Create('Error Asc string');
for i := 0 to Length(Asc) div 2 - 1 do
begin
B := Copy(Asc, i * 2 + 1, 2);
Result := Result + Chr(StrToInt(B));
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
Caption := AscToHex(HexToAsc('1A0F'));
end;楼猪很懒