![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
#1
|
|||
|
|||
|
Hola Amigos.
Estoy intentando escribir unos valores en el Registro pero me da un Error. Me dice que es imposible escribir el dato. Uso Windows professional y hago es lo siguiente: Reg.CreateKey('\Software\Microsoft\Windows\Bmnse'); Reg.WriteDate('MyAppDate',StrToDate('15/03/04')); Reg.WriteInteger('MyAppData',0); Creo la clave 'Bmnse' e intuyo que dentro de la misma me crea lo siguiente:MyAppDate donde guarda 15/03/04 MyAppData donde guarda 0 Pues nada, ni una ni la otra. Dan error al ejecutarse y no puedo escribir ningún dato.Estoy mirando la ayuda pero no consigo ver dónde fallo. Saludos. |
|
#2
|
|||
|
|||
|
En el help de Delphi viene este ejemplo
Código:
procedure TForm1.Button1Click(Sender: TObject);
var
Reg: TRegIniFile;
begin
if Length(NameofKey.Text) or Length(ValueforKey.Text) <=0 then
Showmessage('Either the key name or value is missing.')
else begin
Reg:=TRegIniFile.Create('MyApp');
try
Reg.RootKey:=HKey_Local_Machine; // Section to look for within the registry
if not Reg.OpenKey(NameofKey.Text,False) then
if MessageDlg('The specified key does not exist, create it?'
,Mtinformation,[mbYes,mbNo],0)=mryes then
begin
Reg.CreateKey(NameofKey.Text);
if not Reg.OpenKey(NameofKey.Text,False) then
ShowMessage('Error in Opening Created Key')
else
Reg.WriteString('Main Section','Value1',ValueForKey.Text);
end
else
Reg.WriteString('Main Section','Value1',ValueForKey.Text);
finally
Reg.Free;
end;
end;
end;
|
|
#3
|
|||
|
|||
|
Sigue sin funcionar
Tengo el suiguiente código Código:
If Reg.KeyExists('\Software\Microsoft\Windows\Bmnse') then
begin
If (Today > Reg.ReadDate('MyApp')) then
begin
Application.MessageBox('Mensaje','Atención',MB_OK+MB_IconError);
Halt;
end
else
Application.Run;
end
else
begin
Reg.CreateKey('\Software\Microsoft\Windows\Bmnse');
Reg.WriteDate('MyAppDate',StrToDate('15/03/04'));
Reg.WriteInteger('MyAppData',0);
If (Today > Reg.ReadDate('MyApp')) then
begin
Application.MessageBox('Mensaje','Atención',MB_OK+MB_IconError);
Halt;
end;
end
finally
Reg.Free;
end;
Código:
Reg.WriteDate('MyAppDate',StrToDate('15/03/04'));
Reg.WriteInteger('MyAppData',0);
A ver si así sale... Saludos. |
|
#4
|
|||
|
|||
|
Bueno, me lo he estado mirando (movido por la curiosidad) y he visto porque no te funciona. Te pego el código, pero te aconsejo te fijes en los errores que te da y en la ayuda
![]() Código:
procedure TForm1.Button1Click(Sender: TObject);
const
PathReg = '\Software\Microsoft\Windows\Bmnse';
var
Reg : TRegistry;
Today: TDate;
begin
Today := Date;
Reg := TRegistry.Create;
try
Reg.RootKey := HKey_Local_Machine;
If Reg.KeyExists(PathReg) then
begin
If (Today > Reg.ReadDate('MyAppDate')) then
begin
Application.MessageBox('Mensaje','Atención',MB_OK+MB_IconError);
Halt;
end
else
Application.Run;
end
else
begin
if not Reg.OpenKey(PathReg, true) then
begin
Application.MessageBox('Mensaje', 'Atención', MB_OK or MB_IconError);
Halt;
end;
Reg.WriteInteger('MyAppData', 0);
Reg.WriteDate('MyAppDate', EncodeDate(2004, 3, 15));
If (Today > Reg.ReadDate('MyAppDate')) then
begin
Application.MessageBox('Mensaje', 'Atención', MB_OK or MB_IconError);
Halt;
end;
end
finally
Reg.Free;
end;
end;
PD: a parte de eso, he hecho algún que otro cambio más ya que me parece algo más.... ¿correcto? Espero te sirva |
|
#5
|
|||
|
|||
|
Muchísimas gracias por la ayuda.
Te lo agradezco, de veras. Saludos. |
|
#6
|
|||
|
|||
|
You should change it..
in spanish is like gay. Best Regards Coollliam (L) |
![]() |
|
|
|