procedure TFProcNG.WFTotalNG; var a,b,c:Single; begin SDate:=DateEdit1.Text + FrmMain.FirstT; EDate:=DateToStr(DateEdit2.Date + 1) + FrmMain.FirstT;
WFTotalCDS.Close; WFTotalCDS.CommandText:='select sum(COMPLETE_QTY) as PNum from SWFTotal where PRD_DATE between '''+ DateEdit1.Text +''' and '''+ DateEdit2.Text +''' and COMPANYTYPE = ''WF'' '; WFTotalCDS.Open; B:=WFTotalCDS.FieldByName('PNum').AsFloat;
WFTotalCDS.Close; WFTotalCDS.CommandText:='select sum(ProcNG.Num) AS Num from ProcNG where (ProcNG.NDate between '''+ SDate +''' and '''+ EDate +''') and (Tester = ''外发厂'') '; WFTotalCDS.Open; A:=WFTotalCDS.FieldByName('Num').AsFloat;
C:=(A*1.0)/(B*1.0)*1000000; Label8.Text:=FormatFloat('#,###,##0',C); label9.Text:='外发拦截不良率(PPM)'+#13; label9.text:=label9.Text + '<'+FloatToStr(A)+'-'+FloatToStr(B)+'>'; if C > GetStandValues('外发拦截不良率') then begin Circle3.Stroke.Color:=999988999999; end else begin Circle3.Stroke.Color:=999939229999; end; end;
----------------------------------------------
【个人签名】:玩了多年DELPHI,终于从菜鸟升级成老菜鸟
you can force a "CASTING" when using a type "not explicitly informed", like your "COLOR"... or be,
--> it's expected a TAlphaColor type, BUT you use a "Int64" (big integer)
then, you would can use this: THIS COMPILED WITH NOT WARNING IN 32bits Circle1.Stroke.Color := TAlphaColor(999988999999);
Note: try use a "range valid to integers"!!!
BUT.... 999988999999 is not a "valid integer range"!
//2147483647 valid integer max! //999988999999
any way, you would can have a "overflow" using value "so big"!!!!
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
NOTE 0: the Delphi/Object Pascal, does the "inference" of type according with your value informed, sometimes you'll have a "warning" when doing some like this:
var a, b, x, z: integer; begin a := 65535; b := 65535; //
// x := 65535 * 65535; // [dcc32 Error] Unit1.pas(43): E2099 Overflow in conversion or arithmetic operation // --> 4.294.836.225
// OK = compile! x := a * 65535; x := 65535 * a; x := a * b; end;
then, try use at least a "operand" typed to determine what will be the resulted
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
procedure TForm1.MyIdIcmpClientOnStatus(ASender: TObject; const AStatus: TIdStatus; const AStatusText: string); begin Memo1.Lines.Add('Status: ' + AStatusText); end;
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
NOTE: using "IcmpSendEcho" you needs say TimeOut value > 0
https://learn.microsoft.com/zh-cn/windows/win32/api/icmpapi/nf-icmpapi-icmpsendecho2?redirectedfrom=MSDN
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
TranslateStringToIpAddress(strIP: String; var ipAddress); <-- it can fail to IP not usable, like 0.0.0.0
-------
Stack Overflow Products IcmpSendEcho (ping) fails on Windows 10 Asked 5 years, 1 month ago Modified 5 years ago Viewed 2k times 2
We have a legacy Delphi application which uses IcmpSendEcho (from iphlpapi.dll) to perform echo requests. As I understand it, this performs the same function as "ping" from the command prompt.
On Windows XP, the code below works fine. When the IPv4 address is correct the response is quick and if not error code 11010 (IP_REQ_TIMED_OUT) is returned as expected.
However, on my 32-bit Windows 10 machine, the error code is 87 (ERROR_INVALID_PARAMETER). I've carefully reviewed the Microsoft documentation for IcmpSendEcho and cannot see anything obvious that is wrong.
"ping 200.1.2.121" (the example IPv4 address I use in the code sample) works as expected from the command prompt in both XP and 10.
type PIpAddress = ^TIpAddress; TIpAddress = record case Integer of 0: (S_un_b: TSunB); 1: (S_un_w: TSunW); 2: (S_addr: LongWord); end; IpAddress = TIpAddress;
procedure TranslateStringToIpAddress(strIP: String; var ipAddress); var phe: PHostEnt; pac: PChar; begin try phe := GetHostByName(PChar(strIP)); if (Assigned(phe)) then begin pac := phe^.h_addr_list^; if (Assigned(pac)) then begin with TIpAddress(ipAddress).S_un_b do begin by1 := Byte(pac[0]); by2 := Byte(pac[1]); by3 := Byte(pac[2]); by4 := Byte(pac[3]); end; end else begin raise Exception.Create('Error getting IP from HostName'); end; end else begin raise Exception.Create('Error getting HostName'); end; except FillChar(ipAddress, SizeOf(ipAddress), #0); end; end;
function Ping(strIpAddress : String) : Boolean; const ICMP_ECHO_BUFFER = 128; // Works as low as 28 on Windows XP (nothing works on Windows 10) var address: IpAddress; dwReplies: DWORD; {$IFDEF DBG} dwErrorCode: DWORD; {$ENDIF} abyReplyBuffer: array[1..ICMP_ECHO_BUFFER] of BYTE; begin // Use this function to determine if an IPv4 address can be reached Result := False;
// "m_cache.hPingHandle" is generated earlier with a call to "IcmpCreateFile" if (m_cache.hPingHandle = INVALID_HANDLE_VALUE) then Exit;
{$IFDEF DBG} if (dwReplies = 0) then begin dwErrorCode := GetLastError(); // dwErrorCode = 87 (ERROR_INVALID_PARAMETER, "The parameter is incorrect") Application.MessageBox( PAnsiChar(Format('WinError = %d', [dwErrorCode])), 'Ping failed', MB_ICONEXCLAMATION); end; {$ENDIF}
// Success? Result := (dwReplies <> 0); end;
// Usage elsewhere in the application... Ping('200.1.2.121'); // Works on Windows XP, but fails on Windows 10 delphiwindows-10ipv4
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3