Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Registro de windows con delphi (https://www.clubdelphi.com/foros/showthread.php?t=71164)

maxinitto 04-12-2010 00:57:48

Registro de windows con delphi
 
Hola:

El caso es que llevo ya 2 semanas buscando por google la manera de guardar en el registro, un valor el cual no se me guarda como yo quiero, bueno...
Tengo este valor "1C 00 00 00 41 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 00 00 00" y el tipo de clave es "REG_BINARY" y su nombre es "ShellState", ubicada en "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer", ¿por que diablos al introducir ese valor los numeros "00" me los elimina delphi? uso este codigo sacado de una pagina para guardar valores en el registro.

Código Delphi [-]
procedure SetRegistryData(RootKey: HKEY; Key, Value: string;
  RegDataType: TRegDataType; Data: variant);
var
  Reg: TRegistry;
  s: string;
begin
  Reg := TRegistry.Create(KEY_WRITE);
  try
    Reg.RootKey := RootKey;
    if Reg.OpenKey(Key, True) then begin
      try
        if RegDataType = rdUnknown then
          RegDataType := Reg.GetDataType(Value);
        if RegDataType = rdString then
          Reg.WriteString(Value, Data)
        else if RegDataType = rdExpandString then
          Reg.WriteExpandString(Value, Data)
        else if RegDataType = rdInteger then
          Reg.WriteInteger(Value, Data)
        else if RegDataType = rdBinary then begin
          s := Data;
          Reg.WriteBinaryData(Value + hola, PChar(s)^, Length(s));
        end else
          raise Exception.Create(SysErrorMessage(ERROR_CANTWRITE));
      except
        Reg.CloseKey;
        raise;
      end;
      Reg.CloseKey;
    end else
      raise Exception.Create(SysErrorMessage(GetLastError));
  finally
    Reg.Free;
  end;
end;

Y yo hago esto:

Código Delphi [-]
SetRegistryData(HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Explorer\', 'ShellState 2', rdBinary, ConvertirHexToString('1C 00 00 00 41 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 00 00 00'));

y no queda ni una maldito cero y al no quedar ninguna no funciona lo que quiero hacer (algo simple modificar la forma de abrir los archivos en windows, si con 1 click o 2 clicks) xdddd aver si alguien me echa un cable llevo ya 2 semanas erre que te erre xd

Gracias de antemano

maxinitto 04-12-2010 17:59:10

me respondo yo solo xd ya encontre la manera:

Código Delphi [-]
SetRegistryData(HKEY_CURRENT_USER,'Software\Microsoft\Windows\CurrentVersion\Explorer\','ShellState'  ,rdBinary,#$1C#$00#$00#$00#$41#$08#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$  00#$00#$09#$00#$00#$00);

habia que añadir los caracteres
Código:

#$
para que te guarde el valor tal y como tu lo metes lo posteo por si a alguien le sucede algo similar, saludos

casacham 11-01-2011 21:43:39

Buen Aporte
 
Es un buen aporte. Gracias!!


La franja horaria es GMT +2. Ahora son las 18:45:27.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi