易截截图软件、单文件、免安装、纯绿色、仅160KB

关于delphi Move函数的用法详解

  使用delphi多年,前些天忽然遇到不会string转pbyte,很是失落,此时对于编程基本功的重要性深有体会.这其中用到MOVE函数.
 搞了好一会才搞明白其用法.所以想贴出来帮助需要帮助的人.
var
   s:string;
   ps:Pchar;
   b:pbyte;
   len:integer;
begin
   s:=edit1.Text; //字符串
   ps:=pchar(s); //转成pchar类型,
   len:=length(s);//取字符串长度,占用多少字节
   getmem(b,len);//申请内存,pchar,pbyte在使用前都必须要申请内存,因为他们是指针.
   move(ps^,b^,len);//这里 ps^意思是pchar指向内存数据的第一个字节地址,B^是表示申请内存的第一个字节地址,这样就可以一个一个字节的移到b里去了.
   memo1.Text:=pchar(b);//显示.
   freemem(b);
end;
有些人遇到的困惑是为什么 move(s,b,len)不行呢?同样我也遇到这样的困惑.
看了一样move的函数源码才明白.
procedure       Move( const Source; var Dest; count : Integer );
{$IFDEF PUREPASCAL}
var
  S, D: PChar;
  I: Integer;
begin
  S := PChar(@Source);//取内存地址
  D := PChar(@Dest);//取内存地址
  if S = D then Exit;
  if Cardinal(D) > Cardinal(S) then
    for I := count-1 downto 0 do
      D[I] := S[I]
  else
    for I := 0 to count-1 do
      D[I] := S[I];
end;
如果直接传入s,
 
S := PChar(@Source);//取内存地址\
 就相当于取的字符串S地址的地址.
如果传入的是ps^
S := PChar(@Source);//取内存地址
 就相当于取pchar 所指向字符串实际数据的地址.


相关文档:

Delphi实现的MIME邮件格式解析类库

研究了一下Pop3的邮件接收协议,然后随手写了一个Pop3的邮件接收控件!Pop3的邮件协议实际上是很简单的,知道那几个命令就行了,与服务器之间
的交互是一问一答得方式,控制起来也容易,相对而言邮件格式的解析倒是更加麻烦一点!于是也便顺带着将MIME邮件格式给熟悉了一下!总归说来,规律性比
较强,先获取最大的顶层框 ......

Delphi in a Unicode World Part I

 ---
Delphi in a Unicode World Part I: What is Unicode, Why do you need
it, and How do you work with it in Delphi?
By: Nick
Hodges
原文链接:http://dn.codegear.com/article/38437
Abstract: This article discusses Unicode, how Delphi developers
can benefit from using Unicode, and ho ......

Delphi in a Unicode World Part II

Delphi in a Unicode World Part II:  New RTL Features and
Classes to Support Unicode
By: Nick
Hodges
原文链接:http://dn.codegear.com/article/38498
Abstract: This article will cover the new features of the Tiburon
Runtime Library that will help handle Unicode strings.
//
 & ......

改写了一个常用的DELPHI的加解密函数

DELPHI
//////////////////////////////////
Function   EncrypKey   (Src:String;   Key:String):string;
  var  
  idx   :integer;  
  KeyLen   :Integer;  
  KeyPos   :Integer; &nbs ......

在Delphi中解密Magento加密的信用卡号

问题背景:
       公司希望使用Magento来进行接单,而后把订单导入到一个ERP系统中(订单处理引擎)。
问题:
       在使用WebService从Magento中获取Payment信息时,信用卡是被加密的(法律规定不允许在数据库中存储信用卡的明文信息)!
      ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号