调用360杀毒

发布时间 2023-09-03 16:28:03作者: Tag
function Get360SDPath:string;
const
 AppsPath:string= '\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths';
 S60SD:string='360sd.exe';
var
 ARegistry:TRegistry;
 Applist:Tstringlist;
 i:integer;
begin
 Result := '';
 ARegistry := TRegistry.Create;
 with ARegistry do
 begin
  RootKey := HKEY_LOCAL_MACHINE;
  if OpenKey(AppsPath,False) then
  begin
   Applist := TStringList.Create;
   GetKeyNames(Applist);
   for i := 0 to Applist.Count -1 do
    if UpperCase(Applist[i]) = UpperCase(S60SD) then
    begin
     if OpenKey(AppsPath+'\'+S60SD,False) then
     begin
      Result := ReadString('path');
      if Result <> '' then
       Result := '"'+Result+'\'+S60SD+'"';
     end;
     Break;
    end;
  end;
  CloseKey;
  Free;
 end;
end;


procedure CheckFileTo360(filepath:string);
var
 StartUpInfo: TStartupInfo;
 lpSecurityDescriptor: TSecurityAttributes;
 lpThreadAttributes: TSecurityAttributes;
 ProcessInfo: TProcessInformation;
 Path360:string;
begin
 if not FileExists(filepath) then
  Exit;
 Path360 := Get360SDPath;
 if Path360 <> '' then
 begin
  ShellExecute(0,nil, pchar('"'+Path360+'"'), pchar('"'+filepath+'"'),nil,SW_SHOWNORMAL);
  SetRetData(0,'');
  Exit;
 end
 else
 begin
  SetRetData(2,'找不到360杀毒,请安装360杀毒。');
  ShellExecute(0,'open',pchar('https://sd.360.cn/'), '',nil,SW_SHOWNORMAL);
 end;
end;