Ver Mensaje Individual
  #1  
Antiguo 04-12-2010
maxinitto maxinitto is offline
Miembro
 
Registrado: may 2010
Posts: 45
Reputación: 0
maxinitto Va por buen camino
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
Responder Con Cita