本文整理自网络,侵删。
最近写刻录程序时用到了int64计算比例的功能,integer的范围是4G,而普通DVD光盘容量就是4.3G,直接计算是通不过编译的
因此用了一种取巧的方法,把两个数据右移16位,然后计算比例,当数据小于2的16次方(64k,接近VCD容量的万分之一)时,当作最小进度(如1%)处理
代码如下:
function GetProgress: Integer;var nReadSize, nCapibility: Integer;begin nReadSize := Integer(FWriteSize shr 16); nCapibility := Integer(FCapibility shr 16 ); Result := Round( (nReadSize / nCapibility) * 100 ); if (Result = 0) and (nReadSize > 0) then Result := 1;end;
https://blog.csdn.net/youthon/article/details/7963161
相关阅读 >>
Delphi tms web core messagedlg对话框 yes no
Delphi webbrowser载入自定义html内容并显示
更多相关阅读请进入《Delphi》频道 >>