virtualbox nat 效率慢

Nat 介面打開後 網路傳輸慢
需使用 VBoxManage modifyvm 修改 natdnshostresolver natdnsproxy 2個參數
$ VBoxManage modifyvm "" –natdnshostresolver1 on
$ VBoxManage modifyvm "" –natdnsproxy1 on

前後可以使用 比較時間
time curl -s http://tw.yahoo.com

發表於 未分類 | 發表迴響

Delphi as is self

as (operator ) 運算子, 是用來 型態轉換 ,會將 左方運算元型態 轉為 右方運算元型態
語法:
object as class
例:
procedure TForm1.Button1Click(Sender:TObject);
begin
showmessage((Sender as TButton)).Name;
end;
is 運算子,檢驗 左方運算子物件實體 是否屬於 右方運算元類別 或 子類別,回傳值為 Boolen: True or False
語法:
object is class
注意:
is 回傳 True 或 False 那是在允許使用 is 運算子狀態下, 若在不允許狀態下會產生 編譯錯誤 而不是 False

發表於 未分類 | 發表迴響

zfs 陣列故障排除步驟

1.
zpool status #查看陣列狀態,如有故障 有硬碟問題會出現 io delay,分區出現 faulted, zfs 陣列狀態為degraded

2.
zpool offline zsysvol ata-OLD-HD #故障硬碟設定離線
zpool detach zsysvol ata-OLD-HD #故障硬碟設定離線(不建議此指令)
detach與offline的差別:
detach: 若沒有其它有效的備份碟的話,執行此指令會被拒絕。若此碟可能還會被加回此儲存池(pool)的話,請用offline來替代。

3.
再次用 zpool status 檢查硬碟是否離線,離線後更換硬碟

4.
用 hdparm -i /dev/sd? 查出新hd 代號
zpool replace -f zsysvol ata-OLD-HD ata-NEW-HD

5.
watch -n 1 zpool status -v #持續觀察是否建立
(如果zpool status 舊硬碟還在,下 zpool detach zsysvol ata-OLD-HD)

有些情况下可能需要关机后才能移除硬盘,这时如果重新启动时出现“failed to import zfs名”的报错,那么解决方案如下:
1.开机进入boot选项后,按“e”键,进入编辑模式,在quiet前加入“rootdelay=35”,再按“ctrl+x”键进入。
2.进入系统后,可以修改grub在quiet前加入rootdelay=35,修改后长期有效

發表於 未分類 | 發表迴響

.vimrc vim 方便編輯

"#######################################################
set nocompatible

"#######################################################
syntax enable
set number
set noruler
set ignorecase
set smartcase
set incsearch
set cindent
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set smarttab
set confirm
set backspace=indent,eol,start
set history=500
set showcmd
set showmode
set nowrap
set autowrite
set pastetoggle=
"set mouse=a

"#######################################################
" Color
set t_Co=256
colo torte
set cursorline
set cursorcolumn
set hlsearch
hi CursorLine cterm=none ctermbg=DarkMagenta ctermfg=White
hi CursorColumn cterm=none ctermbg=DarkMagenta ctermfg=White
hi Search cterm=reverse ctermbg=none ctermfg=none

發表於 未分類 | 發表迴響

Delphi建構函式和解構函式

delphi的建構函式的定義是:
constructor create;
delphi的解構函式的定義是:
destructor destroy;

解構函式是不能過載的,但是建構函式是可以過載的。
建構函式在過載的時候要在後面加“overload”,
constructor create;overload;
constructor create(i:integer);overload;
注意,只有兩個建構函式以上才叫過載,只有一個就不用“overload;”了。

預設的建構函式是:constructor create; 如果有過載的話,那麼預設的建構函式後面也要加overload,正象上面的例子一樣。
delphi建構函式在類外定義在什麼位置呢?在implementation的後面。下面給出一個例項,可以從這個例項中看出建構函式的定義:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)   
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

TMyForm1 = class(TForm1)    //自定義一個TMyForm1類
public
constructor Create; overload;  //建構函式有過載
constructor Create(I: Integer); overload; //過載一個建構函式
end;

var
Form1: TForm1;

implementation
{$R *.dfm}
constructor TMyForm1.Create;   //這裡定義建構函式
begin
inherited Create(nil);  //inherited 表示呼叫父類的建構函式
end;
constructor TMyForm1.Create(I: Integer);
begin
inherited Create(nil);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
A: TMyForm1;
begin
A := TMyForm1.Create(1);
A.Show;
end;

end.

發表於 未分類 | 發表迴響

Delphi 分割字串函數 Extracestrings

//分割字符串 ExtractStrings
var
s: String;
List: TStringList;
begin
s := ‘about: #delphi; #pascal, programming’;
List := TStringList.Create;
ExtractStrings([';',',',':'],['#',' '],PChar(s),List);
//第一个参数是分隔符; 第二个参数是开头被忽略的字符

ShowMessage(List.Text); //about
//delphi
//pascal
//programming
List.Free;
end;

發表於 未分類 | 發表迴響

Delphi常用系統函式總結

Delphi常用系統函式總結
字串處理函式
Unit System
函式原型 function Concat(s1 [, s2,..., sn]: string): string; 說明 與 S := S1 S2 S3 …; 相同. 將字串相加.
函式原型 function Copy(S: string; Index, Count: Integer): string;說明 S : 字串. Indexd : 從第幾位開始拷貝. Count : 總共要拷貝幾位. 從母字串拷貝至另一個字串.
函式原型 procedure Delete(var S: string; Index, Count:Integer);說明 S : 字串. Indexd : 從第幾位開始刪. Count : 總共要刪幾位. 刪除字串中的數個字元.
函式原型 procedure Insert(Source: string; var S: string; Index: Integer);說明 Source : 子字串. S : 被插入字串. Indexd : 從第幾位開始插入. 將一個子字串插入另一個字串中.
函式原型 function Length(S: string): Integer; 求字元數
函式原型 function Pos(Substr: string; S: string): Integer;說明 Substr : 子字串.S : 母字串. 尋找子字串在母字串中的位置.
函式原型 function LowerCase(const S: string): string; 將字串全部轉為小寫字母.
函式原型 function UpperCase(const S: string): string; 將字串全部轉為大寫字母.
pos(obj,target) 在target字串中找出第一個出現obj的第一個字元位置,如果找不到,返回0.
function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;功能 返回替換後的字串說明 rfReplaceAll為替換全部內容;rfIgnoreCase為忽略大小寫
function StringToGUID(const S: string): TGUID;功能 返回字串S轉換成全域性標識說明 如果字串非法將觸發異常
function GUIDToString(const GUID: TGUID): string;功能 返回全域性標識GUID轉換成字串
函式原型 procedure Str(X [: Width [: Decimals ]]; var S); 將數值轉換為格式化的字串.說明 X : 欲轉換的整數 or 實數. Width : 格式化長度.(Integer) Decimals : 小數點位數.(Integer)
函式原型 procedure Val(S; var V; var Code: Integer); 將字串轉為數字.說明 S : 欲轉換的字串. V : 轉換後的整數 or 實數.Code : Code = 0 表示轉換成功.
Unit SysUtils
函式原型 function NewStr(const S: string): PString; 在 heap 中配置一個新的字串空間給PString 指標.
函式原型 procedure DisposeStr(P: PString); 在 heap 中釋放一個字串空間 PString指標.
函式原型 function IntToHex(Value: Integer; Digits: Integer): string;
函式原型 function IntToStr(Value: Integer): string;
函式原型 function StrToInt(const S: string): Integer;
函式原型 function StrToIntDef(const S: string; Default: Integer): Integer; 說明 Value : 欲轉換的整數. Digits : 欲轉換為幾位數的 Hex.
函式原型 function Trim(const S: string): string; 將字串前後的空白及控制字元清掉.
函式原型 function TrimLeft(const S: string): string; 將字串左邊的空白及控制字元清掉.
函式原型 function TrimRight(const S: string): string; 將字串右邊的空白及控制字元清掉.
函式原型 function AdjustLineBreaks(const S: string): string; 將字串的換行符號全部改為#13#10
函式原型 function StrAlloc(Size: Cardinal): PChar; 配置字串空間. 說明 Size=字串最大空間 1
函式原型 function StrBufSize(Str: PChar): Cardinal; 傳回由 StrAlloc 配置空間的大小
函式原型 function StrCat(Dest, Source: PChar): PChar; 字串相加.
函式原型 function StrComp(Str1, Str2 : PChar): Integer; 比較兩字串大小.
函式原型 function StrCopy(Dest, Source: PChar): PChar; 拷貝字串.
函式原型 procedure StrDispose(Str: PChar); 釋放StrAlloc or StrNew所配置的空間.
函式原型 function StrECopy(Dest, Source: PChar): PChar; 拷貝字串並傳回字串結束位址.
函式原型 function StrEnd(Str: PChar): PChar; 傳回字串結束位址.
函式原型 function StrIComp(Str1, Str2:PChar): Integer; 比較兩字串大小.(不分大小寫)
函式原型 function StrLCat(Dest, Source: PChar; MaxLen: Cardinal): PChar;字串相加.(指定長)
函式原型 function StrLComp(Str1, Str2: PChar; MaxLen: Cardinal):Integer; 比較兩字串大小.(指定長)
函式原型 function StrLCopy(Dest, Source: PChar; MaxLen: Cardinal): PChar; 拷貝字串.(指定長)
函式原型 function StrLen(Str: PChar): Cardinal; 傳回字串長度.(不含終止位元)
函式原型 function StrLIComp(Str1, Str2: PChar; MaxLen: Cardinals): Integer; 比較兩字串大小.(指定長,不分大小寫)
函式原型 function StrLower(Str: PChar): PChar; 將字串全部轉為小寫字母.
函式原型 function StrMove(Dest, Source: PChar; Count:Cardinal): PChar; 從來源字串拷貝n個Bytes到目標r串.(不含終止位元)
函式原型 function StrNew(Str: PChar): PChar; 配置字串空間.
函式原型 function StrPas(Str: PChar): string; 將 null-terminated 字串轉為Pascal-style 字串.
函式原型 function StrPCopy(Dest: PChar; Source: string): PChar; 拷貝 Pascal-style 字串到null-terminated 字串.
函式原型 function StrPLCopy(Dest: PChar; const Source: string; MaxLen: Cardinal): PChar; 拷貝 Pascal-style 字串到null-terminated 字串.(指定長)
函式原型 function StrPos(Str1, Str2: PChar): PChar; 子字串在母字串中的位置.(第一個位置) 說明 Str1 母字串;Str2 子字串
函式原型 function StrUpper(Str: PChar): PChar; 將字串全部轉為大寫字母.
StrAlloc 配置一個最大長度為Size-1 的緩衝區給null 結尾字串function StrAlloc(Size: Word): PChar;
StrBufSize 傳回由StrAlloc 配置的字串緩衝區內可以儲存的最大字元數。StrBufSize( S: PChar ): Cardinal;
StrCat連結兩個字串並傳回該字串。function StrCat(Dest, Source: PCar): PChar;
StrComp 比照兩個字串。function StrComp(Str1, Str2 : Pchar): Integer;
StrCopy 拷貝Source 字串到Dest 上。function StrCopy(Dest, Source: PChar): PChar
StrDispose 釋回一個字串空間。function StrDispose(Str:PChar);
StrECopy 拷貝Source 字串到Dest 上並傳回指向該字串結尾的指標。function StrECopy(Dest, Surce: Pchar): Pchar;
StrEnd 傳回一指標指向字串的結尾function StrEnd(Str: Pchar): Pchar;
StrLCat 將Source 字串連結到Dest 字串後,並傳回連結的字串。function StrLCat(Dest, Source:PCar; MaxLen: Word): PChar;
StrIComp 比較兩個字串具無大小寫區別function StrIComp(Str1, Str2:Pchar): Integer;
StrLComp 比較兩個字串到所指定的最大長度function StrLComp(Str1, Str2:Pchar; MaxLen: Word): Integer;
StrLCopy 從一字串拷貝指定字元數到另一字串Function StrLCopy(Dest,Source:PChar;MaxLen: Cardinal): PChar;
StrLen 傳回字串的長度。function StrLen(Str: PChar):Cardinal;
StrLIComp 比較兩個字串到所指定的最大長度具無大小寫區別。function StrLIComp(Str1, Str2:PChar; MaxLen: Word):Integer;
StrLower 將字串轉成小寫。function StrLower(Str: PChar):PChar;
StrMove 拷貝Count 字元數,從Source 到Dest字串。function StrMove(Dest, Source:PChar; Count: Cardinal): PChar
StrNew 從堆積配置一個字串。function StrNew(Str: PChar):PChar;
StrPas 將null 結尾字中轉成一個Pascal 格式字串。function StrPas(Str: Pchar):String;
StrPCopy 拷貝一個Pascal 格式字串到一個null結尾字串。Function StrPCopy(Dest:PChar;Source: String): PChar;
StrPLCopy 拷貝MaxLen 所指字元數,從Pascal格式字串到null 結尾字串。Function StrPLCopy(Dest:Pchar;cost Source: string;MaxLen: Word): PChar;
StrPos 傳回一指標指向在Str1 內最先出現 Str2 字串的位置。function StrPos(Str1, Str2: Pchar): Pchar;
StrScan 傳回一指標指向在Str 字串中第一個出現chr 字元的位置。function StrScan(Str: PChar; Chr: Char): PChar;
StrRScan 傳回一指標指向在Str 子串中最後出現chr 字元的位置。function StrRScan(Str: Pchar; Chr: Char): PChar;
StrUpper 將字串轉成大寫。function StrUpper(Str: PChar):PChar;
日期與時間函式 (Date and Time Routines)
Unit: SysUtils
Date 傳回今天日期。function Date: TDateTime;
DateTimeToStr 將時間格式轉為字串。function DateTimeToStr(DateTime: TDateTime):String;
DateTimeToString 將時間格式轉為字串。procedure DateTimeToString(var Result: string;const Format: string;DateTime: TDateTime);
DateToStr 將日期格式轉為字串。function DateToStr(Date: TDateTime): String;
DayOfWeek 傳回今天星期幾。function DayOfWeek(Date: TDateTime): Integer; 傳回值是一整數,1~7. 星期日為1.
DecodeDate 分解所指定的日期為年、月、日。procedure DecodeDate(Date: TDateTime;var Year, Month, Day:Word);
DecodeTime 分解所指定的日期為時、分、秒。procedure DecodeTime(Time: TDateTime;var Hour, Min, Sec,MSec: Word);
EncodeDate 傳回將年、月、日所組合的日期格式。function EncodeDate(Year, Month, Day: Word):TDateTime;
EncodeTime 傳回將時、分、秒所組合的時間格式。function EncodeTime(Hour, Min, Sec, MSec:Word): TDateTime;
FormatDateTime 以指定的格式傳回日期時間。function FormatDateTime(const Format: string;DateTime: TDateTime):String;
Now 傳回現在的日期時間。function Now: TDateTime;
StrToDate 將字串轉為日期格式。function StrToDate(const S:string): TDateTime;
StrToDateTime 將字串轉為日期時間格式function StrToDateTime(const S: string): TDateTime;
StrToTime 將字串轉為時間格式。function StrToTime(const S:string): TDateTime;
Time 傳回現在時間。function Time: TDateTime;
TimeToStr 將時格式轉為字串。function TimeToStr(Time:TDateTime): String;
檔案管理函式
Unit: SysUtils
函式原型 function ExtractFileDir(const FileName: string): string;
函式原型 function ExtractFileDrive(const FileName: string): string;
函式原型 function ExtractFileExt(const FileName: string): string;
函式原型 function ExtractFileName(const FileName: string): string;
函式原型 function ExtractFilePath(const FileName: string): string;
函式原型 function DeleteFile(const FileName: string): Boolean;
函式原型 function RenameFile(const OldName, NewName: string):Boolean;
函式原型 function FileExists(const FileName: string): Boolean;
函式原型 procedure FindClose(var F: TSearchRec);
函式原型 function FindFirst(const Path: string; Attr: Integer; var F: TSearchRec): Integer;
函式原型 function FindNext(var F: TSearchRec): Integer;說明 成功傳回0
ChangeFileExt 變更檔案的副檔名。
function ChangeFileExt(const FileName,Extension: string):string; DateTimeToFileDate 將Delphi 的日期格式轉換為DOS的日期格式。
functionDateTimeToFileDate(DateTime:TDateTime): Longint;
DeleteFile 刪除一個檔案。function DeleteFile(const FileName: string):Boolean;
DiskFree 傳回磁碟的可用空間。function DiskFree(Drive: Byte): Longint;
DiskSize 傳回指定磁碟的容量大小。function DiskSize(Drive: Byte): Longint;
ExpandFileName 傳回一個完整的路徑及檔名字串。function expandFileName(const FileName: string):string;
ExtractFileExt 傳回檔案的副檔名。function ExtractFileExt(const FileName string):string;
ExtractFileName 傳回檔案的檔名。function ExtractFileName(const FileName: string):string;
ExtractFilePath 傳回檔案的路徑。function ExtractFilePath(const FileName: string):string;
FileAge 傳回檔案的年紀function FileAge(const FileName: string):Longint;
FileCreate 以指定檔名建立一個檔案。function FileCreate(const FileName: string):Integer;
FileClose 關閉指定的檔案。procedureFileClose(Handle: Integer);
FileDateToDateTime 將DOS 的日期格式轉為Delphi 的日期格式。function FileDateToDateTime(FileDate: Longint):TDateTime;
FileExists 判別檔案是否存在。function FileExists(const FileName: string):Boolean;
FileGetAttr 傳回檔案屬性。function FileGetAttr(const FileName: string):Integer;
FileGetDate 傳回檔案的日期及時間。function FileGetDate(Handle: Integer): Longint;
FileRead 從指定的檔案讀入資料。function FileRead(Handle:Integer; var Buffer;Count:Longint):Longint;
FileSearch 在目錄列中搜尋指定的檔案。function FileSearch(constName, DirList: string):string;
FileSeek 改變檔案遊標的位置。function FileSeek(Handle: Integer;Offset: Longint;Origin: Integer):Longint;
FileSetAttr 設定檔案屬性。function FileSetAttr(const FileName: string;Attr:Integer): Integer;
FileSetDate 設定檔案的日期及時間。procedure FileSetDate(Handle: Integer; Age:Longint);
FileOpen 開啟檔案。function FileOpen(const FileName: string; Mode:Word): Integer;
FileWrite 寫資料到檔案。function FileWrite(Handle:Integer;const Buffer; Count:Longint): Longint;
FindClose 終止找尋第一個/下一個的動作。procedure FindClose(var SearchRec: TSearchRec);
FindFirst 尋找第一個符合的檔案並設定其屬性。
function FindFirst(const Path: string;Attr: Word; var F:TSearchRec): Integer;
FindNext 傳回下一個符合的檔案。function FindNext(var F:TSearchRec): Integer;
RenameFile 變更檔名。function RenameFile(const OldName,NewName: string):Boolean;
轉換函式(Transfer Routines)
Unit: System
Chr 傳回ASCII 碼所對應的字元。function Chr(X: Byte): Char;
Delphi 原始碼任務 ( http://home.kimo.com.tw/bruce0211/ ) 打字整理15
High 傳回叄數在範圍內的最高值。function High(X);
Low 傳回叄數在範圍內的最低值。function Low(X);
Ord 傳回一個有序型態所對應的順序值。function Ord(X): Longint;
Round 將一個實數值四捨五入而傳回整數值。function Round(X: Real):Longint;
Trunc 將一個實數值去尾而傳回整數值。function Trunc(X: Real):Longint;
pred(x) pred(‘D’)=’C', pred(true)=1;
succ(x) succ(‘Y’)=’Z', succ(pred(x))=x
ord(x) 求x在字符集中的序號,如ord(‘A’)=65
chr(x) chr(65)=’A’
round(x) 四捨五入
trunc(x) trunc(4.8)=4,trunc(‘-3.6′)=-3
upcase(x) upcase(‘a’)=’A’
hi(I) hi($2A30)=$2A
lo(I) lo($2A30)=$30
random(n) 產生[0,n)間的隨機整數
sizeof(name) 求出某型別或變數在記憶體中佔用的位元組數
swap(num) 交換int的高低位 swap($3621)=$2136
Frac 求一個實數的小數部份
R := Frac(123.456); { 0.456 }
R := Frac(-123.456); { -0.456 }
Int 求一個實數的整數部份
R := Int(123.456); { 123.0 }
R := Int(-123.456); { -123.0 }
函式原型 function High(X); 傳回註腳的最大值
函式原型 function Low(X); Low 傳回註腳的最小值.
函式原型 function Ord(X): Longint; 傳回列舉型態的數值.
函式原型 function Round(X: Extended): Longint; 將實數轉為整數.(有四捨五入)
函式原型 function Trunc(X: Extended): Longint; 將實數轉為整數.(小數直接捨棄)
函式原型 function VarArrayCreate(const Bounds: array of Integer; VarType: Integer): Variant; 建立一個variant array.
函式原型 function VarArrayOf(const Values: array of Variant): Variant; 建立一個簡單的一維variant array
函式原型 function VarArrayLock(var A: Variant): Pointer; 將variant陣列==>指定給一陣列變數.
函式原型 procedure VarArrayUnlock(var A: Variant); 解除上述的指定.
函式原型 function VarIsArray(const V: Variant): Boolean; 傳回Variant是否為一個陣列.
函式原型 function VarIsNull(const V: Variant): Boolean; 傳回Variant是否為NULL.
函式原型 function VarAsType(const V: Variant; VarType: Integer): Variant; 將Variant轉為另外一個型態的Variant.
函式原型 procedure VarCast(var Dest: Variant; const Source: Variant; VarType: Integer);說明 VarType不可為varArray or varByRef.
函式原型 function VarType(const V: Variant): Integer; 傳回Variant的型態.
函式原型 procedure VarClear(var V: Variant); 將variant清除,成為Unassigned狀態.
函式原型 procedure VarCopy(var Dest: Variant; const Source: Variant); 拷貝一個variant.說明 與Dest:=Source;效果一樣.
函式原型 function VarFromDateTime(DateTime: TDateTime): Vari ant; 將DateTime轉為Variant.
函式原型 function VarToDateTime(const V: Variant): TDateTime; 將Variant轉為DateTime.
函式原型 function Hi(X): Byte; 傳回高位元數字.Hi($1234); { $12 }
函式原型 procedure Include(var S: set of T; I:T); 說明 加入I元素到S中. 加入一個元素到一組元素.
函式原型 function Lo(X): Byte; Lo($1234); { $34 }
函式原型 procedure Move(var Source, Dest; Count: Integer); 從來源變數拷貝n個Bytes到目的變數.
函式原型 function ParamCount: Integer; 直接由執行檔後加上傳入變數的個數.
函式原型 function ParamStr(Index: Integer): string;說明 ParamStr(0);傳回執行檔的名稱及完整目錄.
函式原型 function Random [ ( Range: Integer) ]; 說明 0<=X 函式原型 function Swap(X); Swap 將一組變數的高低位元交換.
函式原型 function UpCase(Ch: Char): Char; 將一字元轉為大寫字母.
函式原型 procedure Dec(var X[ ; N: Longint]);說明 Dec(X) ==> X:=X-1; Dec(X,N) ==> X:=X-N; 使變數遞減.
函式原型 procedure Inc(var X [ ; N: Longint ] );說明 Inc(X) ==> X:=X-1;Inc(X,N) ==> X:=X-N; 使變數遞增.
函式原型 function Odd(X: Longint): Boolean; 檢查是否為奇數.
函式原型 function Assigned(var P): Boolean; Assigned 測試指標變數是否為nil. 說明 當@P=nil ==> 傳回FALSE
數學函式
Abs 傳回叄數的絕對值。 function Abs(X);
ArcTan 傳回正切函式的反函式值。 function ArcTan(X: Real): Real;
Cos 傳回餘弦函式值 function Cos(X: Real): Real; (X 以弧度為單位)。
Exp 傳回自然指數值。 function Cos(X: Real): Real;
Frac 傳回叄數的小數部份。 function Frac(X: Real): Real;
Int 傳回叄數的整數部份。 function Int(X: Real): Real;
Ln 傳回自然對數值。 function Ln(X: Real): Real;
Pi 傳回圓周率π的值。 function Pi: Real;
Sin 傳回正弦函式值。 function Sin(X: Real): Real;
Sqr 傳回叄數的平方。 function Sqr(X: Real): (Real);
Sqrt 傳回叄數的平方根。 function Sqrt(X: Real): Real;
輸出入函式Unit: System
AssignFile 指定一個檔案到檔案變數。procedure AssignFile(var f, String);
CloseFile 關閉檔案。procedure CloseFile(var F);
Eof 判斷是否已到檔案結尾。
Typed or untyped files: functionEof(var F): BooleanText files:function Eof [ (var F: Text) ]:Boolean;
Erase 清除檔案內容。procedure Erase(var F);
FilePos 傳回目前檔案遊標位置。function FilePos(var F): Longint;
FileSize 傳回檔案的大小function FileSize(var F):Longint;
GetDir 傳回指定磁碟的工作目錄。procedure GetDir(D: Byte; var S: String);
IOResult 傳回最後I/O 執行的狀態。function IOResult: Integer;
MkDir 建立一子目錄。procedure MkDir(S: String);
Rename 變更外部檔案的檔名。procedure Rename(var F; Newname);
Reset 開啟一個已存在的檔案。procedure Reset(var F [: File; Recsize: Word ] );
Rewrite 建立並開啟一個新檔。procedure Rewrite(var F: File [; Recsize: Word ] );
RmDir 刪除一個空目錄。procedure RmDir(S: String);
Seek 移動檔案遊標。procedure Seek(var F; N: Longint);
Truncate 刪截目前位置以後的檔案內容。procedure Truncate(var F);
浮點數轉換函式 Unit: SysUtils
FloatToDecimal 將浮點數值分成小數及整數部份的數字傳回。
procedure FloatToDecimal(var Result: TFloatRec;Value:Extended;Precision, Decimals:Integer);
FloatToStrF 依照指定格式將浮點數轉成字串描述。
function FloatToStrF(Value: Extended; Format:TFloatFormat;Precision,Digits: Integer): string;
FloatToStr 將浮點數轉成字串描述。function FloatToStr(Value: Extended): string;
FloatToText 將所給的浮點數值,分成小數及整數部份的數字依照格式傳回。
function FloatToText(Buffer: Pchar; Value:Extended;Format:TFloatFormat;Precision,Digits: Integer): Integer;
FloatToTextFmt 將浮點數依照格式轉成字串傳回。
function FloatToTextFmt(Buffer: PChar; Value:Extended;Format: PChar) :Integer;
FormatFloat 將浮點數值依照Format 格式傳回。
function FormatFloat(constFormat: string;Value:Extended):string;
StrToFloat 將所給字串轉成一個浮點數值。
function StrToFloat(const S: string): Extended;
TextToFloat 將一個null 結尾字串轉成浮點數值
function TextToFloat(Buffer: PChar;var Value:Extended): Boolean;
流程控制函式 Unit: System
Break 終止迴圈。如for, while 及repeat 迴圈。
Continue 繼續迴圈。如for, while 及repeat 迴圈。
Exit 離開目前的區塊。procedure Exit;
Halt 停止程式的執行並回到作業系統。
動態配置函式Unit: System
Dispose 釋回一個動態變數。procedure Dispose(var P: Pointer);
Free 釋放一個物件複本。procedure Free;
FreeMem 釋回一給定大小的動態變數。procedure FreeMem(var P:Pointer; Size: Word);
GetMem 建立一個指定大小的動態變數,並由Pointer 叄數傳回位址。procedure GetMem(var P:Pointer; Size: Word);
New 建立一個新的動態變數,並將Pointer 叄數指向它。procedure New(var P: Pointer);function New( ):Pointer;
MaxAvail 傳回連續最大的可配置空間。function MaxAvail: Longint;
MemAvail 傳回所有的可配置空間。function MemAvail: Longint;
指標和位址函式 Unit: System
addr 傳回指定物件的位址。function Addr(X): pointer;
Assigned 判斷是否一個函式或程式是nil function Assigned(var P):Boolean;
CSeg 傳回CS 程式段暫存器的內容。function CSeg: Word;
DSeg 傳回DS 資料段暫存器的內容。function DSegt: Word;
Ofs 傳回叄數的偏移位址。function Ofs(X): Word;
Ptr 將所指定的節段及偏移位址組合到一個指標。function Ptr(Seg, Ofs: Word):Pointer;
Seg 傳回叄數的節段位址。function Seg(X): Word;
SPtr 傳回SP 堆疊存器的內容。function SPtr: Word;
SSeg 傳回SS 堆疊段暫存器的內容。function SSeg: Word;
控制檯函式 Unit: WinCrt
AssignCrt 將文字檔連結到一個控制檯視窗。 procedure AssignCrt(var f: Text);
ClrEol 清附遊標位置到該行最後的所有字元。procedure ClrEol;
ClrScr 清附螢幕並重置遊標至左上角。 procedure ClrScr;
CursorTo 移動遊標至給定座標。 procedure CursorTo(X, Y:Integer);
DoneWinCrt 結束控制檯視窗。 procedure DoneWinCrt;
GotoXY 移動遊標至給定座標。 procedure GotoXY(X, Y: Byte);
InitWinCrt 建立控制檯視窗。 procedure InitWinCrt;
KeyPressed 判斷是否有一按鍵。 function KeyPressed:Boolean;
ReadBuf 從控制檯視窗讀入一行。 function ReadBuf(Buffer: Pchar;Count: Word):
ReadKey 讀取按鍵字元。function ReadKey: Char;
ScrollTo 捲動控制檯視窗至顯示位置。procedure ScrollTo(X, Y: Integer);
TrackCursor 捲動控制檯視窗宜到遊標可見。procedure TrackCursor;
WhereX 傳回遊標的X 座標。function WhereX: Byte;
WhereY 傳回遊標的Y 標標。function WhereY: Byte;
WriteBuf 寫入一區塊字元到控制檯視窗。procedure WriteBuf
WriteChar 寫一個字元到控制檯視窗。procedure WriteChar(CH: Char);

發表於 未分類 | 發表迴響

win10 暫停用 printer spooler

power shell
stop-service -name spooler -force
set-service-name spooler -startuptype disable

發表於 未分類 | 發表迴響

server 2019 smb v1 開放

先打開 powershell 檢查 smbv1 狀態
Get-SmbServerConfiguration | Select EnableSMB1Protocol

先安裝 "SMB 1.0/CIFS File Sharing Support"

在 gpedit.msc
電腦設定-系統管理範本-網路-Lanman 工作站-啟用不安全來賓登入 勾 已啟用

再次打開 powershell 檢查 smbv1 狀態
Get-SmbServerConfiguration | Select EnableSMB1Protocol

正常應該要
EnableSMB1Protocol
———————–
True

發表於 未分類 | 發表迴響

[Delphi] override , overload , inherited 遺傳用法

https://www.cnblogs.com/760044827qq/p/3777369.html

[override]-過載
Override 表示是覆蓋方法;要求祖先類中必須有該方法的定義,並且參數的順序和類型

override 關鍵字來說明函數覆蓋的。被覆蓋的函數必須是虛(virtual)的,或者是動態(dynamic)的,也就是說該函數在聲明時應該包含這兩個指示字中的一個,比如:
procedure Draw; virtual;
在需要覆蓋的時候,只需要在子類中用override 指示字重新聲明一下就可以了。
procedure Draw; override;

[overload]-重載
overload 表示是重載方法;用於一個類中有許多同名的方法帶著不同的參數表的情形;

方法定義關鍵字的說明:
virtual 虛類型
dynamic 動態
overload 重載
override 重寫
abstract 抽象

virtual方法為執行速度做了優化,而dynamic方法則為代碼大小做了優化;經常被覆蓋的
virtual 和 dynamic定義的虛函數,都是為了子類override用的,只不過它們的實現不一樣。vitrual 占用的空間大點,但速度快些。dynamci正好相反.
virtual 使用時機:很末端的類別,或這個方法在後代可能加以改寫 應宣告成virtual 來爭取速度
dynamic 使用時機:越基礎的類別,或後代改寫方法可能性不高 宣告成 dynamic ,省的進出點一在出現子代的VMT
abstract 使用時機:建立標準,父 本身是不做事的, 但 子 代 要在implementation 實作區一定要有程式碼,不然 編譯 會通過但依執行會出錯

message 表示是消息處理方法;在關鍵字message後面的值指明了這個方法要響應的消息;用消息處理方法來響應Windows的消息,這樣就不用直接來調用它;

abstract 表示是抽象方法;是沒有實現的方法,並且必須是virtual或dynamic方法,即
procedure DoSomething; virtual; abstract;

reintroduce表示是重新聲明的方法;用於方法的名稱與祖先類中的某個方法名稱相同的情形;

[inherited]
inherited 就是调用祖先类的函数,如果不带参数就是默认调用同名函数
如果带参数则表明子类中的函数个数可能比祖先类要多取其中的几个参数传过去
例如
祖先类有个函数 Create(AName:string);
子类有个函数 Create(AName:string;AComponent:TObject);override;
那么子类的Create函数内就可以这样调用祖先类:
procedure TAClass.Create(AName:string;AComponent:TObject);
begin
Inherited Create(AName);
end;

發表於 未分類 | 發表迴響