All pastes #24453 Raw Edit

Untitled

public text v1 · immutable
#24453 ·published 2005-10-02 18:03 UTC
rendered paste body
function DetectBT : PChar; stdcall;
var
  R : TRegistry; T,P : PChar;
begin
  R := TRegistry.Create;
  R.RootKey := HKEY_CLASSES_ROOT;
  if (R.KeyExists('bittorrent\shell\open\command\') = TRUE) then
  begin
    R.OpenKey('bittorrent\shell\open\command\',FALSE);
    if (R.ReadString('') <> '') then
    begin
      T := PChar(R.ReadString(''));
      T := PChar(Copy(StrPas(T),2,Length(StrPas(T))-1));
      T := PChar(Copy(StrPas(T),1,Pos('"',StrPas(T))-1));
      P := T;
      T := PChar(ExtractFileName(StrPas(T)));
      if (LowerCase(StrPas(T)) = 'btdownloadgui.exe') then
      begin
        result := PChar('1|'+P);
      end
      else
      begin
        result := '2|?';
      end;
    end
    else
    begin
      result := '2|?';
    end;
  end
  else
  begin
    result := '2|?';
  end;
  FreeAndNil(R);
end;

Then I have exports:

exports
  DetectBT;