Delphi字符串、PChar与字符数组之间的转换
Delphi字符串、PChar与字符数组之间的转换
设有以下三个变量:
var
s:string;
p:pchar;
a:array[1..20] of char;
那么三者之间的转换如下:
1、字符串到PChar
p:=PChar(s);
2、PChar到字符串
s:=p;
3、PChar到字符数组
StrCopy(@a,p);
4、字符数组到PChar
PChar(@a);
5、字符串与字符数组之间的转换就只有通过PChar来中转了。例如下面这个例子:
procedure TForm1.btn1Click(Sender: TObject);
var
str:array[1..10] of char;
begin
StrCopy(@str,PChar(mmo1.Text));
mmo2.Text:=PChar(@str);
end;
相关文档:
今天在大理剑川做监控联网工程,遇到2台DIY的PC-DVR,联网很不顺利。机器的软件是盗版破解的,只破解了服务器端,客户端未破解,还有就是版本也不对。最后发现软件下有一ActiveX控件可以做联网使用,于是想把这个OCX引入项目软件工程。在引入的时候delphi提示coreide70.bpl报错,错误代码:00000019 ......
unit unitMain;
interface
uses
Registry, shlobj,
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TExtForm = class(TForm)
ledExtension: TLabeledEdit;
ledAssocApp: TLabeledEdit;
GetAssocApp: TButton;
AssocTh ......
http://developer.51cto.com/art/200510/7205.htm
[DELPHI]网络邻居复制文件
uses shellapi;
copyfile(pchar('newfile.txt'),pchar('//computername/direction/targer.txt'),false);
[DELPHI]产生鼠标拖动效果
通过MouseMove事件、DragOver事件、EndDrag事件实现,例如在PANEL上的LABEL:
var xpanel,ypanel,xlabel,yla ......
最近做一个项目,要用Delphi,以前从未学过,好是费劲啊,哈哈光是字符串切割这个问题就困扰了几个小时,通过查资料终于解决,在这与大家分享一下
Function split(src: pchar; ch: char):TStringList;
// 分割字符串
var
i: Integer;
tmp : string;
begin
Result:=TStringList.Create;
......