2017年2月14日 星期二

Word + Google拼音 不要預設字型 simsun 解決方法

windows10 左下角 
1.【右鍵】->【執行】->執行【regedit】。
2.展開HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts
3.
找到“E”英文字開頭尋找0804,替換所有0804成爲0404。
4. 修改[Layout Text]的數值,成爲"Google正體",修改完成後存檔。
5. 從控制臺的輸入法設定中Chinese Taiwan的區域内加入
Google正體

2014年1月12日 星期日

runtime move component

type Tcontrolacess= class(Tcontrol);

procedure TForm3.ControlCMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
     ReleaseCapture;
   Twincontrol(sender).Perform(WM_SYSCOMMAND, $F012, 0 );
end;

procedure TForm3.FormCreate(Sender: TObject);
var i:integer;
begin
  for i:= 0 to componentcount -1 do
    begin
      if components[i] is TWincontrol then
      Tcontrolacess(components[i]).onmousedown := ControlCMouseDown;
    end;
end;

2014年1月11日 星期六

Delphi Create Owner Free 元件建立與釋放

Delphi 元件建立與釋放
var component1
begin
component1  := Tcomponent.Create(Owner);
Owner = nil --> xxx.Free; 自己釋放
Owner <> nil --> xxx 由Owner 釋放 ,不用自己釋放
....
end;
//必須是繼承自TComponent
// Create(Owner: TComponent) 才有Owner
//Tchildcpmponent = class(TComponent);

// TObject ,TPersistent
//Create; 無Owner 必須自己釋放

Delphi Change Owner 變更可視元件(TWinControl)擁有者

//變更可視元件(TWinControl)擁有者

procedure ChangeOwner(Control: array of TComponent;
  newOwner: TWinControl);
var
  i: integer;
begin
  for i := low(Control) to high(Control) do
  begin
    newOwner.InsertComponent(Control[i]);
    if Control[i] is TWinControl then
      TWinControl(Control[i]).Parent := newOwner;
  end;
end;
//Example
procedure TForm3.Button3Click(Sender: TObject);
begin
  ChangeOwner([cxGrid1, cxGrid1DBTableView1, cxGrid1Level1,
    cxGrid1DBTableView1Column1, cxGrid1DBTableView1Column2,
    cxGrid1DBTableView1Column3, cxGrid1DBTableView1Column4],         Panel1);
end;

2013年12月29日 星期日

delphi mutex


//single mode
program
 Project1;

uses
  Windows,
  Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.RES}

const
  MutexName = 'onlyone_MUTEX';
  ClassName = 'TForm1';
  WindowName = 'Form1';
var
  Mutex: THandle;
  Handle: THandle;
begin
  Mutex := OpenMutex(MUTEX_ALL_ACCESS, False, MutexName);
  if Mutex <> 0 then
  begin
    Handle := FindWindow(ClassName, WindowName);
    SetForegroundWindow(Handle);
    Exit;
  end;
  CreateMutex(nil, False, MutexName);
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

delphi Critical Section、Event、Mutex、Semaphores

用於多緒TThread 等待
臨界區(Critical Section)
Txxx=class
  protected
    FSection: TRTLCriticalSection;
...
Txxx.Create;
InitializeCriticalSection(FSection); 建立臨界區

EnterCriticalSection(FSection) 進入臨界區
try
   DO...
finally
LeaveCriticalSection(FSection 離開臨界區
end;

Txxx.destory;
DeleteCriticalSection(FSection);

事件(Event)
CreateEvent() 建一個信號量
SetEvent()      on
RsetEvent(  )  off
CloseHandle()
互斥量(Mutex)
CreateMutex()
OpenMutex()
ReleaseMutex()
CloseHandle()
信號量(Semaphores)
CreateSemaphore()
OpenSemaphore()
ReleaseSemaphore()
CloseHandle()

WaitForSingleObject(等待訊號,等待時間)單一訊號
WaitForMultipleObjects(等待數量,等待訊號,等全部,等待時間)多訊號

Return code/value_
WAIT_OBJECT_0 to (WAIT_OBJECT_0 +nCount– 1)
WAIT_ABANDONED_0 to (WAIT_ABANDONED_0 +nCount– 1)
WAIT_TIMEOUT
WAIT_FAILED ...

訊號類型
Change notification
Console input
Event
Memory resource notification
Mutex
Process
Semaphore
Thread
Waitable timer

2013年12月28日 星期六

數位簽章概念理解

角色
使用者A:文件製作者
使用者B:文件接收者

數位文件: OFFICE /PDF/TXT ....
當使用者A要將製作的數位文件傳送給使用者B時的問題
1.     如何確保數位文件沒有被修改
解決方案:Message Digest(訊息摘要)
                 使用一種數學函式,將文件運算產生一個數值,這個數值稱為hashmessage Digest,如果文件有變更過,則這個數值也會變更,因此可以用來檢查郵件對是否被修改.

2.使用者B如何確認文件是使用者A

解決方案:Digital signatures (數位簽名)
將上述的Message Digest使用自己的私鑰來加密,文件包含了使用
文件發出
A.使用A用私鑰加密Message Digest
B.使用者A將文件與加密後的Message Digest傳送給使用者B
C.使用者A的公鑰
文件接收
C.使用者B收到文件後用hash函數工具計算出訊息摘要A
D.使用者B用使用者提供的公鑰解密訊息摘要B
E.比對 訊息摘要A 訊息摘要B 即可確認文件無誤由使用者A發出

3.如何確保使用者A不是假冒的

解決方案: Certificate Authority(憑證的認證中心)第三方公證

使用者A與使用者B都有一個憑證證明他們是誰(如身份證),我們透過Certificate Authority(憑證的認證中心),幫我們確認身份,公私鑰也由憑證中心發放,公鑰存放在憑證中心,私鑰自己保管