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;

lcd liquid crystal display 偏光片 Polarizer

lcd liquid crystal display 偏光片 Polarizer

polarizers magnet Faraday 偏光片 法拉第 效應

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

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

自己做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