unitdll.pas

来自「在delphi中实现windows核心编程.原书光盘代码核心编程.原书光盘代码」· PAS 代码 · 共 50 行

PAS
50
字号
unit UnitDll;

interface

uses
  SysUtils,
  Classes,
  Windows,
  Dialogs;

var
  hThreadHandle: Dword;
  dwThreadID: Dword;
  
implementation

{在左上角显示时间}
procedure ThreadProc;
var
  hScreenDC: hdc;
  SystemTime: _SYSTEMTIME;
  Temp: string;
  MyOutput: PChar;
begin
  while true do
  begin
    Sleep(100);
    hScreenDC := GetDC(0);
    GetLocalTime(SystemTime);
    Temp := format('Current Time is %d-%d-%d %d:%d:%d', [SystemTime.wYear,
      SystemTime.wMonth,
        SystemTime.wDay,
        SystemTime.wHour,
        SystemTime.wMinute,
        SystemTime.wSecond]);
    MyOutPut := Pchar(temp);
    TextOut(hScreenDC, 0, 0, MyOutPut, lstrlen(MyOutPut));
    ReleaseDC(0, hScreenDC);
  end;
end;

initialization
      hThreadHandle := CreateThread(nil, 0, @ThreadProc, nil, 0, dwThreadID);
finalization
      if (hThreadHandle <> 0) then
        TerminateThread(hThreadHandle, 0);
        
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?