2018年11月13日 星期二

Undocumented MessageBoxTimeOut function 時間 倒數 訊息


http://www.delphibasics.info/home/delphibasicssnippets

Undocumented MessageBoxTimeOut function
function MessageBoxTimeOut( 
      hWnd: HWND; lpText: PChar; lpCaption: PChar; 
      uType: UINT; wLanguageId: WORD; dwMilliseconds: DWORD): Integer; stdcall;
function MessageBoxTimeOutA( 
      hWnd: HWND; lpText: PChar; lpCaption: PChar; 
      uType: UINT; wLanguageId: WORD; dwMilliseconds: DWORD): Integer; stdcall;

function MessageBoxTimeOutW( 
      hWnd: HWND; lpText: PWideChar; lpCaption: PWideChar; 
      uType: UINT; wLanguageId: WORD; dwMilliseconds: DWORD): Integer; stdcall;

implementation 

// this const is not defined in Windows.pas 
const 
  MB_TIMEDOUT = 32000; 

function MessageBoxTimeOut; externaluser32 name 'MessageBoxTimeoutA'; 
function MessageBoxTimeOutA; external user32 name 'MessageBoxTimeoutA'; 
function MessageBoxTimeOutW; external user32 name 'MessageBoxTimeoutW';


var 
  iResult: Integer; 
  iFlags: Integer; 
begin 
  // Define a MessagBox  with an OK button and a timeout of 2 seconds 
  iFlags  := MB_OK or MB_SETFOREGROUND or MB_SYSTEMMODAL or MB_ICONINFORMATION;
  iResult := MessageBoxTimeout( 
   Application.Handle, 
   'Test a timeout of 2 seconds.', 
   'MessageBoxTimeout Test', iFlags, 0, 2000); 

  // iResult will = 1 (IDOK) 
  ShowMessage(IntToStr(iRet)); 

  // Define a MessageBox with a Yes and No button and a timeout of 5 seconds 
  iFlags  := MB_YESNO or MB_SETFOREGROUND or MB_SYSTEMMODAL or MB_ICONINFORMATION; 

  iResult := MessageBoxTimeout( 
    Application.Handle, 
    'Test a timeout of 5 seconds.', 
    'MessageBoxTimeout Test', iFlags, 0, 5000); 

  // iResult = MB_TIMEDOUT if no buttons clicked, otherwise 
  // iResult will return the value of the button clicked 

  case iResult of 
  IDYES:  // Pressed Yes button 
    ShowMessage('Yes'); 

  IDNO:  // Pressed the No button 
    ShowMessage('No'); 

  MB_TIMEDOUT: // MessageBox timed out 
    ShowMessage('TimedOut'); 
  end; 
end;

Using NtDeleteFile from Delphi 刪除 檔案



Using NtDeleteFile from Delphi

The required structures (not defined in Delphi) are UNICODE_STRING and OBJECT_ATTRIBUTES.
function NtDeleteFile(ObjectAttributes:POBJECT_ATTRIBUTES):DWORD; stdcall; external 'ntdll.dll'; RtlDosPathNameToNtPathName_U

2018年11月12日 星期一

完整 抓取 記憶體 驗證 鏡像

memory text Dynamic Section Image Verification


LoadLibrary GetDllDirectory  GetProcAddress FreeLibrary GetModuleHandle DllMain MapViewOfFile


Dynamic TEXT Section Image Verification - CodeProject
Dynamic Code Checksum Generator - CiteSeerX
Dynamic Section - Assembly Language Programmer's Guide

memory Dynamic  process Section Image list api monitor

2018年11月7日 星期三

delphi VCL Web-Frameworks RIA




http://delphi625.rssing.com/chan-54815889/all_p14.html

delphi VCL Web-Frameworks

delphi Web ria

Rich Internet Application Frameworks


VCL Web-Frameworks
RealThinClient
IntraWeb
AthTek WebXone
UniGui
Raudus
xxm
DelphiOnRails
WebHub VCL
Kitto
p2js
extPascal
DelphiMVCFramework
Pas2Php

2018年5月24日 星期四

delphi float double 浮點數

https://github.com/Tominator2/HEXtoIEEE-754

http://www.davdata.nl/math/floatingpoint.html

http://www.efg2.com/Lab/Mathematics/NaN.htm
http://www.efg2.com/Lab/Library/Delphi/MathInfo/index.html

http://docwiki.embarcadero.com/RADStudio/Tokyo/en/About_Floating-Point_Arithmetic

http://rvelthuis.de/articles/articles-floats.html


IEEE standard for floating-point 754 1985 2008  

https://ieeexplore.ieee.org/document/4610935/definitions?ctx=definitions

https://en.wikipedia.org/wiki/Double-precision_floating-point_format

var
  f:Single;
  pb:  pbyte;
  pba:array[1..sizeof(Single)] of byte;
  ttb4,ttb3,ttb2, ttb1 : Byte;
  i : Integer;
  s:string;
  Lines: TStrings;
begin

  s:='';

  f := string.ToSingle(Edit1.Text);
  pb := addr(f);
  for I := 1 to SizeOf(f) do
  begin
    pba[I]:= pb^;
    inc(pb);
  end;
  I:=1;

  ttb4:= pba[SizeOf(f)];
  ttb3:= pba[SizeOf(f)-1];
  ttb2:= pba[SizeOf(f)-2];
  ttb1:= pba[SizeOf(f)-3];

  s:= s +'Sign:'+ byte(ttb4 shr 7).ToHexString+',';
  s:= s +',Exp:'+ byte((ttb4 shl 1) or (ttb3 shr 7)).ToHexString;
  s:= s+',Frac:'+ byte((ttb3 shl 1 )shr 1).ToHexString + byte(ttb2).ToHexString+ byte(ttb1).ToHexString;

  s:= s +',Full:';
  for I := SizeOf(f) downto 1 do
  begin
    s:= s +','+ pba[I].ToHexString;
  end;
  I:=1;

  //32 bits (1 for the sign 8 for the exponent, and 23 for the mantissa).

  Memo1.Lines.Add(FormatFloat('0000000.0000000',f));
  Memo1.Lines.Add(s);
  Memo1.Lines.Add(
    '[Sign:'+ f.Sign.ToString+
    '][Exp:'+ word(f.Exp).ToHexString+
    '][Frac:'+ f.Frac.ToHexString
    +']');
  Memo1.Lines.Add('Exponent:'+ f.Exponent.ToHexString);
  Memo1.Lines.Add('Mantissa:'+ f.Mantissa.ToHexString);


2018年5月15日 星期二

從 window 找到 application path PID

 Enumerating All Processes
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682623.aspx

Snapshot Process 32 First Process Next Enum Processes
Kernel32 CreateToolhelp32Snapshot
CreateToolhelp32Snapshot
Process32First 找到第一個
Process32Next 下一個
EnumProcesses
QueryFullProcessImageName  
https://msdn.microsoft.com/zh-tw/library/windows/desktop/ms684919(v=vs.85).aspx

EnumWindows() 列舉出所有視窗
FindWindow() FindWindowEx() 找到窗體
GetWindowThreadProcessId() 找 process ID 擁有這 窗
OpenProcess() 得到 HANDLE
GetModuleFileNameEx()
GetProcessImageFileName()
QueryFullProcessImageName()
GetWindowModuleFileName()


EnumWindows FindWindow FindWindowEx GetWindowThreadProcessId OpenProcess GetModuleFileName GetProcessImageFileName QueryFullProcessImageName GetWindowModuleFileName

如何創建 單一 唯一執行 執行檔 傳 參數 CreateParams paramstr


How to run a single instance of an application
http://delphidabbler.com/articles?article=13
delphi Process Param Create Params paramstr
如何創建 單一 唯一執行 執行檔 傳 參數

本篇教你 傳遞 參數 給 程式 , 可以 確認 運作 或是 重複的 執行  或是 結束他

首先動作是

傳遞 個  window message WM_COPYDATA

運作如

先找  window 存在?
喚醒她
傳送window message
決定 是否結束他

你可以用 findwindows 找到自己 預留 的接收端

SwitchToPrevInst 你可以 前後找

可以對 其他 window 做 傳送 SendMessage( Wdw, WM_COPYDATA, 0, LPARAM(@CopyData)

Data 必須是 動態產生的  alloc ...



後面有下載

2018年5月7日 星期一

delphi 把個 物件 元件 object component 存檔 save file

http://www.swissdelphicenter.ch/en/showcode.php?id=1626
https://stackoverflow.com/questions/698536/saving-a-tobject-to-a-file
https://torry.net/pages.php?id=96
http://jedqc.blogspot.tw/2006/02/d2006-what-on-earth-are-these-explicit.html
http://www.jed-software.com/files/ExplicitProps.zip
delphi runtime design system save
http://bitwisemag.co.uk/2/Add-A-Runtime-Form-Designer-To.html
delphi component stream binary save
http://www.delphisources.ru/pages/faq/master-delphi-7/content/LiB0045.html
https://theroadtodelphi.com/tag/rtti/
delphi property procedure save file Method
如何欺騙 Delphi 將一般獨立 procedure 當成 TxxEvent of Class;
Using resource files with Delphi
delphi component stream serialization
https://www.thoughtco.com/function-or-procedure-as-parameter-1057606

...save a TImagelist with all its images to a file?


// For writing components use WriteComponentResFile(path + source filename , component name source)
WriteComponentResFile('C:\imagelist1.bin',imagelist1);

// For reading the data back to a component:
// component := ReadComponentResFile(path + source filename , component name traget)
imagelist1 := ReadComponentResFile('c:\imagelist1.bin', nilas TImagelist;


function ComponentToString(Component: TComponent): string;

var
BinStream:TMemoryStream;
StrStream: TStringStream;
s: string;
begin
BinStream := TMemoryStream.Create;
try
StrStream := TStringStream.Create(s);
try
BinStream.WriteComponent(Component);
BinStream.Seek(0, soFromBeginning);
ObjectBinaryToText(BinStream, StrStream);
StrStream.Seek(0, soFromBeginning);
Result:= StrStream.DataString;
finally
StrStream.Free;

end;
finally
BinStream.Free
end;
end;

2018年5月6日 星期日

gps 時間 校正

gps utc conversion arduino


http://www.instructables.com/id/GPS-time-UTC-to-local-time-conversion-using-Arduin/


網路時間協定- 維基百科,自由的百科全書 - Wikipedia


gps time synchronize International GNSS

synchronize Time dhcp

delphi 正則 邏輯搜尋





lcd liquid crystal display 偏光片 Polarizer

lcd liquid crystal display 偏光片 Polarizer

polarizers magnet Faraday 偏光片 法拉第 效應

偏光片 受到 強烈磁性 的 變化 而 改變 偏光的角度

https://www.youtube.com/channel/UCivA7_KLKWo43tFcCkFvydw

穩定 壓縮 複合 木材 刀柄 電化 塑化

stabilized compressed Hybrid Resin Wood

訊息鑑別碼

Message authentication code

訊息鑑別碼- 維基百科,自由的百科全書 - Wikipedia

金鑰雜湊訊息鑑別碼- 維基百科,自由的百科全書 - Wikipedia

https://en.wikipedia.org/wiki/Category:Message_authentication_codes


3SJJ0808金融数据密码机技术白皮书_百度文库

SJL22金融数据密码机技术白皮书V8.0h_图文_百度文库

SJJ1212 Financial HSM Encryption of Data DES 3DES AES SM4

中国人民银行  pboc
 

https://www.ibm.com/support/knowledgecenter/en/linuxonibm/com.ibm.linux.z.wskc.doc/wskc_c_macclc.html
A keyed-hash MAC (HMAC) based message authentication can be used by the HMAC Generate and HMAC Verify verbs.

2018年5月3日 星期四

俄國人 的入口網站

https://yandex.ru


Снег, лёд и океан

地圖


翻譯


幸好網址是英文

自己做cpu 的教學

http://apollo181.wixsite.com/apollo181

APOLLO181 is a homemade didactic 4-bit CPU

 made exclusively of TTL logics and bipolar memories All employed chips are described in the Bugbook® I and II, in particular the 74181 Arithmetic and Logic Unit.

內容講 ㄧ 個 自己做cpu 的教學,及 尊敬的 Dr. Peter R. Rony

Relay Computer ttl 74181


http://www.derivedlogic.com/TTL%20Processor/ttlprocessor.html

http://www.derivedlogic.com/TTL%20Processor/ttlprocessorblog.html

http://www.kswichit.com/8088kit/8088kit.htm

https://eater.net/8bit/

fpge 8086

8086 stack structure 74373

2018年4月30日 星期一

python 3d 統計圖表


https://matplotlib.org/index.html

https://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html

Matplotlib is a Python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms. Matplotlib can be used in Python scripts, the Python and IPython shells, the Jupyter notebook, web application servers, and four graphical user interface toolkits.

python 的 3d 表格工具 函式 庫 提供你快速 產出 3d的 統計圖表 有有許多變的樣式 ,可以 再多種 python script 上 或是主機上

5種 座標系統 平行軸

Delta 水母  Cartesian 龍門 polar coordinate system  極座標系 Scara 平行軸

Delta Cartesian polar Scara cylindrical

Cartesian coordinate system

cylindrical coordinate system Cartesian coordinate system Spherical Coordinates

Meshing Coordinate Global Coordinate Systems

2018年4月25日 星期三

捕捉DOS輸出



Thundax Output 


Кодировка из Win в DOS и из DOS в Win в Delphi 2010 
URL
google

function WinToDos(ASource: String): AnsiString;
var
Ch: PAnsiChar;
begin
Ch := AnsiStrAlloc(Length(ASource) + 1);
CharToOem(PChar(ASource), Ch);
Result := StrPas(Ch);
StrDispose(Ch)
end;

procedure WritelnDos(ASource: String);
begin
Writeln(WinToDos(ASource));
end;
function DosToWin(ASource: AnsiString): AnsiString;
var
Ch: PAnsiChar;
begin
Ch := AnsiStrAlloc(Length(ASource) + 1);
OemToAnsi(PAnsiChar(ASource), Ch);
Result := StrPas(Ch);
StrDispose(Ch)
end;

function DosToWin(ASource: AnsiString): String;
var
Ch: PChar;
begin
Ch := StrAlloc(Length(ASource) + 1);
OemToChar(PAnsiChar(ASource), Ch);
Result := StrPas(Ch);
StrDispose(Ch)
end;


function AsciiToAnsi(AsciiStr: string): string;
var AnsiStr: string;
begin
SetLength(AnsiStr, Length(AsciiStr));
if Length(AsciiStr) > 0 then OemToChar(PChar(AsciiStr), PChar(AnsiStr));
AsciiToAnsi:= AnsiStr;
end;

function AnsiToAscii(AnsiStr: string): string;
var AsciiStr: string;
begin
SetLength(AsciiStr, Length(AnsiStr));
if Length(AnsiStr) > 0 then CharToOem(PChar(AnsiStr), PChar(AsciiStr));
AnsiToAscii:= AsciiStr;
end;

取得系統時間 效能量測

http://codingdelphi.blogspot.tw
Win32 Performance Measurement Options


The five Win32 timing functions provided by the base API (as implemented in KERNEL32.dll) are

GetTickCount,
GetSystemTime()
GetSystemTimeAsFileTime()
QueryPerformanceCounter(),
GetThreadTimes()
GetProcessTimes()
timeGetTime()

References
Java 2 Performance and Idiom Guide, Craig Larman & Rhett Guthrie, Prentice-Hall PTR, 2000.
More Effective C++, Scott Meyers, Addison-Wesley, 1996.
More Exceptional C++, Herb Sutter, Addison-Wesley, 2002.

rtc base timeer timegettime setwaitabletimer ... 最後一頁

GetTickCount function
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724408%28v=vs.85%29.aspx


https://msdn.microsoft.com/en-us/library/windows/desktop/ms724411%28v=vs.85%29.aspx
timeGetTime function
https://msdn.microsoft.com/en-us/library/dd757629.aspx
ntquerytimerresolution NtSetTimerResolution
NtQuerySystemInformation function
https://msdn.microsoft.com/zh-tw/library/windows/desktop/ms724509(v=vs.85).aspx
Articles » Languages » C / C++ Language » General Timers Tutorial
https://www.codeproject.com/Articles/1236/WebControls/?fid=2345&df=90&mpp=25&sort=Position&view=Normal&spc=Relaxed&fr=101&prof=True




Acquiring high-resolution time stamps
QueryPerformanceCounter (QPC)
System.Diagnostics.Stopwatch
QueryPerformanceFrequency
Timestamp Cycle Counter (TSC) - Intel® Developer ... 64-bit register present on all x86 processors since the Pentium.

2018年4月16日 星期一

檔案鏈結 鏡像 備份 同步

mklink  Winodws  建立 symbolic link


Mklink Examples.
mklink [[/d] | [/h] | [/j]]  
File and Directory Linking



Junction v1.07

Windows Sysinternals

mklink

byte 2 bin byte array

var
  a: byte;
  MASK: byte;
  arr : Array[0..7] of byte;
  iindex : byte;
begin
  a:= random($ff);
  MASK := ($80-1);// ($1 shl (sizeof(a)*7) )-1
  //writeln(MASK);
  write('a= ');
  write(a);
  write('= ');
  write(a div 16 );
  write(',');
  write(a mod 16 );
  writeLn('');

//msb 1 byte  to 8byte
  for iindex := 7 downto 0 do
  begin
    if a > MASK then arr[iindex]:=1 else arr[iindex]:=0;
    a:= a shl 1;
    write(arr[iindex]);
  end;
  //writeLn('-----------');