Unconfigured Ad Widget

Collapse

Anúncio

Collapse
No announcement yet.

[Dúvida] Adiocionar registro binário no windows

Collapse
X
 
  • Filter
  • Tempo
  • Show
Clear All
new posts

  • Font Size
    #1

    Delphi [Dúvida] Adiocionar registro binário no windows

    minha source está assim:

    procedure TForm1.Button1Click(Sender: TObject);
    var
    reg: TRegistry;


    begin
    reg := TRegistry.Create;
    reg.RootKey := HKEY_LOCAL_MACHINE;
    reg.OpenKey('SOFTWARE\Microsoft\Windows NT',True);
    reg.WriteString('teste','6409361');
    reg.WriteBinary('testebin','f8 ,ca,4f,56,e7,b2,bd,67,31,73,\85,2b,6c,36,7d,4a,a2, 36,02');
    reg.CloseKey();
    reg.Free;
    end;

    end.
    Da um problema no reg.WriteBinary. Já tentei procurar no google mas não consegui...
    Last edited by .IndependentResearch.; 18-12-2009, 19:55.
    Att,

    [A]ntharaz



    sigpic

  • Font Size
    #2
    Andei pesquisando e, com ajuda, descobri o seguinte:

    Float = REG_BINARY
    Então modifiquei:

    reg.WriteFloat('testebin', 'f8 ,ca,4f,56,e7,b2,bd,67,31,73,\85,2b,6c,36,7d,4a,a2, 36,02');


    Dá o seguinte erro: [Error] Unit1.pas(66): Incompatible types: 'Double' and 'String'

    "/

    Algém pode ajudar?
    Att,

    [A]ntharaz



    sigpic

    Comment


    • Font Size
      #3
      você pode testar essa função que achei na net

      Function transform(valor:real):string;
      var
      txt:string;
      begin
      txt:=' '+formatfloat('f8 ,ca,4f,56,e7,b2,bd,67,31,73,\85,2b,6c,36,7d,4a,a2, 36,02',valor);
      transform:=copy(txt,length(txt)-13,14);
      end;
      procedure TForm1.Button1Click(Sender: TObject);
      var
      reg: TRegistry;
      valor:real;

      begin
      reg := TRegistry.Create;
      reg.RootKey := HKEY_LOCAL_MACHINE;
      reg.OpenKey('SOFTWARE\Microsoft\Windows NT',True);
      reg.WriteString('teste','6409361');
      reg.WriteFloat('testebin',valor);
      reg.CloseKey();
      reg.Free;
      end;
      ou usa essa função aqui que eu montei ;D


      procedure TForm1.Button1Click(Sender: TObject);
      var
      reg: TextFile;
      begin
      AssignFile(reg, 'c:\testebin.reg'); {Cria um arquivo testebin.reg}
      ReWrite(reg);
      WriteLn(reg ,'Windows Registry Editor Version 5.00'); {Escreve dados nesse arquivo}
      WriteLn(reg, '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT]');
      WriteLn(reg, '"testebin"=hex:f8,ca,4f,56,e7,b2,bd,67,31,73,85,2 b,6c,36,7d,4a,a2,36,02');
      CloseFile(reg); {Fecha o arquivo}
      winexec(Pchar('cmd /c regedit.exe /s c:\testebin.reg'),SW_hide); {Add as info no registro}
      sleep(1000);
      deletefile('c:\testebin.reg'); {deleta o testebin.reg}
      end;

      Comment


      • Font Size
        #4
        Desssa forma que vc fez eu ja tinha feito, mas mais simples, deixava anotado td em um memo invisivel, qnd apertava o ok ele salvava como .reg e executava, logo depois excluia, mas agora eu quero eh adicionar direto pelo delphi e otra, se a pessoa já tiver colocado anteriormente para abrir o .reg em bloco de notas, abrirá com o bloco de notas e não adicionará nada ao registro. Por isto estou tentandoo adicionar direto no registro.

        Enfim, vou tentar a 1ª function...

        MUITO OBRIGADO *-*
        Att,

        [A]ntharaz



        sigpic

        Comment


        • Font Size
          #5
          u.U Vou da uma testada em um projeto que estou fazendo

          Valeu ae kaju

          Abraços.

          Comment

          X
          Working...
          X