Delphi 的字元及字串[3] – String 中的秘密

//String 的指標地址及實際的記憶體位址var str: string; pstr: PString; pc: PChar;begin {在沒有給 str 賦值以前, 既然聲明了, 就有了指標地址(@str):} ShowMessage(IntToStr(Integer(@str))); {1244652; 這是在棧中的 str 的指標地址} {但現在還沒有分配真正儲存字串記憶體} ShowMessage(IntToStr(Integer(str))); {0; 0 就是

記憶體管理[6]

本例:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Memo1: TMemo; Memo2: TMemo; procedure

SysUtils.StrLCat

StrLCat 與 StrCat 類似, StrLCat 多出的參數好像是限制結果的長度.unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure

擷取變數類型的函數

Variants 單元下的 VarType 函數可以擷取變數類型, 但它返回的只是一個數字; 需要再結合一下在 System 單元裡定義的這些常量:varEmpty = $0000;varNull = $0001;varSmallint = $0002;varInteger = $0003;varSingle = $0004;varDouble = $0005;varCurrency = $0006;varDate = $0007;varOleStr = $0

SysUtils.StrScan、SysUtils.StrRScan、SysUtils.StrPos

StrScan : 返回一個字元在一個 PChar 串中第一次出現的位置指標;StrRScan : 返回一個字元在一個 PChar 串中最後一次出現的位置指標;StrPos : 返回一個 PChar 串在另一個 PChar 串中第一次出現的位置指標.unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,

擷取集合元素個數 – 回複”鷹@長空”

問題來源: http://www.cnblogs.com/del/archive/2008/05/11/978683.html#1191835unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject);

SysUtils.StrEnd、SysUtils.StrLen

StrEnd 擷取 PChar 串未指標; StrLen 擷取 PChar 串長度.unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure

SysUtils.StrComp、SysUtils.StrIComp

StrComp 和 StrIComp 都是對比 PChar 字串的大小的函數, 只是後者不區分大小寫.unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Button2: TButton;

SysUtils.StrMove

其實這也是個 Copy 函數, 和 Move 沒有關係.unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end;var Form1: TForm1;implementation{$R

記憶體管理[2]

系統給程式的地址數是 4G, 為什麼不是 3G 或 5G? 因為 32 位的指標的最大值就是 $FFFFFFFF, 它不能表示更多了, 究其根源這要回到 CPU 的定址能力、地址匯流排等等.在 Win64 下, 系統給程式的地址數達到了 16EB(0 - $FFFFFFFFFFFFFFFF), 也就是 18446744073709551616 個.不過 Win64 還沒有普及, 我們還得回到實際的 Win32.就這 4G 的地址, 系統還要留下一半($80000000 - $FFFFFFFF,

Delphi 的字元及字串[4] – 字串、字元指標與字元數組

//字串 字元數組var arr: array[0..5] of Char; str: string;begin {可以把字串常量直接賦給字元數組; 但超界不行} arr := 'Delphi'; ShowMessage(arr); {Delphi} {可以把字元數組直接賦給字串變數} str := arr; ShowMessage(str); {Delphi} {其實字串內部也是包含了一個字元數組, 所以能索引訪問, 不過它的索引起始於 1}

Delphi 的字元及字串[6] – Char(AnsiChar)、WideChar 與其編碼的相互轉換

//Char 類型與其編碼值的轉換:var b: Byte; c: Char;begin b := Ord('A'); {返回: 65} b := Ord(#65); {返回: 65} b := Ord($41); {返回: 65} b := Ord(#$41); {返回: 65} b := Byte('A'); {返回: 65} b := Byte(#65); {返回: 65} b := Byte($41); {返回: 65} b := Byte(#$4

記憶體管理[3]

VirtualAlloc 分配的記憶體是以 4K 為最小單位、連續的記憶體位址(但映射到真實的記憶體時它不一定是連續的), 前面說了, 它不適合分配小記憶體(譬如只有幾個位元組的變數); 局部的變數在 "棧" 中有程式自動管理, 那麼那些全域的小變數怎麼辦呢? 這就要用到 "堆".這樣看來, VirtualAlloc 分配的記憶體既不是 "棧" 也不是 "堆"; VirtualAlloc 分配的記憶體位址是連續的, "堆" 中內容一般是不連續的, 所以管理 "堆" 比較麻煩,

SysUtils.StrLComp、SysUtils.StrLIComp

StrLComp、StrLIComp 與 StrComp、StrIComp 基本是一樣的, 只是多了一個參數用來指定有效長度.unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject);

判斷一個對象是否存在, 誰更快?

判斷一個對象是否存在(賦值)的三種辦法如下:if obj nil then ... if Boolean(obj) then ... if Assigned(obj) then ...通過下面的測試, 結論是 obj nil 最慢; Boolean(obj) 與 Assigned(btn) 相當!測試圖:測試源碼:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics,

SysUtils.StrCopy、SysUtils.StrECopy

StrCopy 和 StrECopy 都是複製源 PChar 串到目標 PChar 串, 只是傳回值不同; StrCopy 返回結果的首地址, StrECopy 返回結果的尾(#0)地址.unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm)

SysUtils 中其他 PChar 函數: StrPas、StrNew、StrDispose、StrNextChar、StrFmt、StrLFmt、StrCharLength

//StrPas: 轉換 PChar 為 string; 現在可以直接賦值, 很少用了.var p: PChar; s: string;begin p := 'Delphi'; s := StrPas(p); ShowMessage(s); {Delphi}end;//StrNew、StrDispose: 建立與銷毀 PChar.var p: PChar;begin p := StrNew('Delphi'); ShowMessage(p); {Delphi}

SysUtils.StrLCopy、SysUtils.StrPCopy、SysUtils.StrPLCopy

StrLCopy 只是比 StrCopy 多了一個限制長度的參數; StrPCopy 等價於 StrCopy; StrPLCopy 等價於 StrLCopy.unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) procedure FormCreate(Sender:

SysUtils.StrAlloc、SysUtils.StrBufSize

StrAlloc : 給 PChar 指標分配空間, 並填充 #0;StrBufSize : PChar 緩衝區大小.unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end;var

SysUtils.StrUpper、SysUtils.StrLower

StrUpper 和 StrLower 是轉換 PChar 串的大小寫函數.unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton;

總頁數: 61357 1 .... 4787 4788 4789 4790 4791 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.