Delphi 7 x64 record

Asked

Viewed 526 times

2

I tested on a Windows 8 machine the following: I entered a Windows registry key for startup. On Windows XP and Windows 7 which were 32 bits worked but on Windows 8 which is 64 bits didn’t work. Can I get a little help? How to enter a registry key in Windows 8 - 64 bit? Below is the code I tried.

var
Reg: TRegistry;
S: string;

begin
Reg := TRegistry.Create;
S:= variavelcontendocaminhoearqv;
Reg.rootkey:=HKEY_CURRENT_USER;
Reg.Openkey('software\microsoft\windows\currentversion\run\',true);
Reg.WriteString('programtest',S);
Reg.closekey;
Reg.Free;
end;
  • I just tested now and unfortunately it didn’t work and in this part here Reg := Tregistry.Create(KEY_WRITE OR KEY_WOW64_64KEY); from the error not letting compile :p ... ta fod# I tried everything...

  • Which error appears? Another thing, as you called the Procedure inicializarPrograma?

  • Yes I called correctly... when compiling error: undeclared Identifier: KEY_WOW64_64KEY

  • I updated the answer again, test like that and see if the program is put on startup, go to Run (Windows key + R and type: msconfig)

  • now was :( was testing on my sister’s machine she was now gone chipped kkk ... if anyone can give a test force and see if it works and say would be very grateful ...

  • Well, at least in Windows 7 it worked. In theory it was to work also in Windows 8, one thing you should remember is the WOW! One thing out of context: You can vote for questions and answers who have been helpful to you, your vote is very important to our community.

  • the Win7 you tested is 64bits? ... ok I will vote for yours for sure!

  • OK thank you very much friend, in case you can test in the 8 let us know here or if I get warning you so we stay ahead and informed of the things that work rsrs.

  • qmechanik do a test so take the code I was using that I mentioned above and use to see if it was able to insert in your 64 bit Win7

  • The problem is there’s no KEY_WOW64_64KEY in your code, this is required in 64-bit.. Idea: Why not test in a virtual machine?

  • Well if that Cod doesn’t work already is 80% sure that code works in Win8 rsrs, unfortunately I don’t have 64 bit pc

  • Maycon, when you can test to confirm, give a feedback!

Show 7 more comments

1 answer

4

Perhaps it is necessary to pass the value KEY_WOW64_64KEY in the builder.

// Uses Registry;
procedure inicializarPrograma(App, Caminho: string);
const 
  KEY_WOW64_64KEY = $0100; 
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create(KEY_WRITE OR KEY_WOW64_64KEY); //
  try
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run', True) then
     Reg.WriteString(App, Caminho);
    Reg.CloseKey;
  finally
    Reg.Free;
  end;
end;

Example of use:

inicializarPrograma(Caption, ParamStr(0));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.