字串转字节数组

一、CopyMemory  

var
s:PAnsiChar;
ary:TArray<Byte>;
bt:Byte;
begin
s:='Form Delphi';
SetLength(ary,Length(string(s))+);
CopyMemory(ary,s,Length(s));
mmo1.Clear;
for bt in ary do
begin
mmo1.Lines.Append(Chr(bt));
end;
end;

二、Move

var
s:PAnsiChar;
pb:PByte;
i:Byte;
begin
s:='From Delphi';
GetMem(pb,Length(string(s))+);
Move(s^,pb^,Length(string(s))+);
mmo1.Clear;
{$POINTERMATH ON}
for i:= to Length(string(s)) do
begin
mmo1.Lines.Append(Chr(pb[i]));
end;
{$POINTERMATH OFF}
FreeMem(pb,Length(string(s))+);
end;

三、Move

var
s:PAnsiChar;
pb:PByte;
i:Byte;
begin
s:='From Delphi';
GetMem(pb,Length(string(s))+);
Move(s^,pb^,Length(string(s))+);
mmo1.Clear;
i:=;
while (pb^<>Ord(#)) do
begin
mmo1.Lines.Append(Chr(pb^));
Inc(pb);
Inc(i);
end;
Dec(pb,i);
FreeMem(pb,Length(string(s))+);
end;

Delphi中Move、CopyMemory操作的更多相关文章

  1. Delphi中文本文件的操作

    Delphi中文本文件的操作 相关知识内容: 在对文本文件进行任何处理之前,首先要打开此文本文件.声明变量:通过此变量可以来引用一个文本文件. 打开一个文件需要两步:首先是 AssignFile(), ...

  2. delphi中move函数的正确理解(const和var一样,都是传地址,所以Move是传地址,而恰恰不是传值)太精彩了 good

    我们能看到以下代码var pSource,pDest:PChar;     len: integer;.......................//一些代码Move(pSource,pDest,l ...

  3. Delphi中的dll操作

    利用delphi dll wizard进行dll的编写. 创建:保存时改dll名称 library test2; uses SysUtils, Classes, forms, dialogs; {$R ...

  4. delphi中ini 文件操作记要(1): 使用 TIniFile

    unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  5. Delphi中那些容易混淆的基础(@、^、Addr、Pointer,Move、CopyMemory,GetMem和FreeMem、GetMemory和FreeMemory、New和Dispose、StrAlloc和StrDispose、AllocMem)

    @.^.Addr.Pointer Delphi(Pascal)中有几个特殊的符号,如@.^等,弄清楚这些符号的运行,首先要明白Delphi指针的一些基础知识:指针,是一个无符号整数(unsigned ...

  6. Delphi中那些容易混淆的基础

    @.^.Addr.Pointer Delphi(Pascal)中有几个特殊的符号,如@.^等,弄清楚这些符号的运行,首先要明白Delphi指针的一些基础知识:指针,是一个无符号整数(unsigned ...

  7. Delphi中String类型原理介绍

    Delphi中字符串的操作很简单,但幕后情况却相当复杂.Pascal传统的字符串操作方法与Windows不同,Windows吸取了C语言的字符串操作方法.32位Delphi中增加了长字符串类型,该类型 ...

  8. Delphi中exit、break、continue等跳出操作的区别

    Delphi中表示跳出的有break,continue,abort,exit,halt,runerror等 1.break 强制退出最近的一层循环(注意:只能放在循环里:而且是只能跳出最近的一层循环) ...

  9. Delphi中的操作二进制文件的两个重要函数

    Delphi中的操作二进制文件的两个重要函数 对于通过Byte数组进行文件操作的,在FTP中经常会使用到,我也是在Delphi调用Web Service进行文件的上传和下载时找到这两个函数的,挺好用的 ...

随机推荐

  1. Mybatis_3.基于注解的增删改查

    1.实体类User.java public class User { private int id; private String name; private int age; //getter.se ...

  2. CSS3_文本样式

    1. 文字阴影 text-shadow 使用: text-shadow:    水平方向偏移量    垂直方向偏移量    模糊程度    颜色; #box { text-shadow: 10px 1 ...

  3. react_app 项目开发 (7)_难点集合

    /src/App/Admin/Header 布局 import {Row, Col} from "antd" <div className="header_box& ...

  4. [LeetCode] Sliding Puzzle 滑动拼图

    On a 2x3 board, there are 5 tiles represented by the integers 1 through 5, and an empty square repre ...

  5. ab 站点压力测试工具

    ab--压力测试工具 前端时间由于需要测试一个网站的高并发的情况,使用到了一个ab测试工具,下面是我自己的体验及参考网上别人的博客所写,希望对大家有所帮助. ab工具简介 ab 全称:apache b ...

  6. Apache Flink系列(1)-概述

    一.设计思想及介绍 基本思想:“一切数据都是流,批是流的特例” 1.Micro Batching 模式 在Micro-Batching模式的架构实现上就有一个自然流数据流入系统进行攒批的过程,这在一定 ...

  7. 正则序RegExp

    正则的理解 1.正则的懒惰性    每次在exec()中捕获的时候,只捕获第一次匹配的内容,而不往下不捕获了.我们把这叫正则的懒惰性,每一次捕获的开始位置都是从0开始 解决正则的懒惰性 修饰符g 正则 ...

  8. 下面findmax函数将计算数组中的最大元素及其下标值,请编写该函数。

    #include <stdio.h> void findmax ( int s[ ], int t, int *k ) { int i; *k = ; ; i < t; i++) { ...

  9. JDK8之The type java.util.Map$Entry cannot be resolved

    eclipse+tomcat7+jdk1.6上面报错的方式我的解法方法是吧jre8换成6的就好了选中项目->右键->java build path ->找到jre system li ...

  10. python hashlib模块 md5加密 sha256加密 sha1加密 sha512加密 sha384加密 MD5加盐

      python hashlib模块   hashlib hashlib主要提供字符加密功能,将md5和sha模块整合到了一起,支持md5,sha1, sha224, sha256, sha384, ...