Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 440
  • Last Modified:

How to create a registry key with TReg in Win7

I'm trying to make an older program work under Win7 and I'm frustrated with the registry error I get. The simple openkey worked fine under XP but creates this error now:

"Failed to set data for" the specific key name.

The problem is that OpenKey always returns false and WriteString obviously creates an error unless it's braced between if/then pair as shown. Is it a rights issue bec/ I have included a vistaTheme manifest. Reading reg works, writing does not.


myReg := TRegistry.Create;
  try
    myReg.RootKey := HKEY_LOCAL_MACHINE;
    if myReg.OpenKey('SOFTWARE\myApp\', true) then
    begin
        myReg.WriteString('ProgName:', 'TestProg');
        showmessage('Worked!')
    end
    else
     showmessage('Failed!')
  finally
    myReg.Free;
  end;

Open in new window

0
IOOI
Asked:
IOOI
  • 3
  • 3
1 Solution
 
ThievingSixCommented:
Try HKEY_CURRENT_USER.
0
 
IOOIAuthor Commented:
It has to be HKEY_LOCAL_MACHINE bec/ one of the things this prog does is to set up auto run on win start for all users using the 'Software\Microsoft\Windows\CurrentVersion\Run' key.
0
 
ThievingSixCommented:
Try compiling the program, right clicking it and clicking Run as Administrator.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
IOOIAuthor Commented:
Do users have to run as admin as well? That would be no good. To rephrase the original question: how do I run a prog for all users at win start up as inconspicuously as Vista would allow? Also, shouldn't the inclusion of the vistaTheme file take care of the elevated right issue? Why doesn't it? Thanks.
0
 
ThievingSixCommented:
I personally do not run vista yet. If it works when you right click and run as administrator then the accepted answer found here: http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_22755023.html would help you.

The two things I would make sure you do is that you use the correct type of manifest and your installation program sets the folder permissions automatically.
0
 
IOOIAuthor Commented:
Many thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now