topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday December 12, 2024, 4:56 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Registry Help...  (Read 5525 times)

Renox

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 58
    • View Profile
    • Donate to Member
Registry Help...
« on: March 12, 2007, 01:24 PM »
I have many different programs that I have written but I have not been able to register them with windows so that when u double-click the executable it doesn't prompt you to Allow the program to run... I know that alot of installers offer the option but I was wondering if anyone knew how to do it using a batch file or with Visual C++... All I need to learn how to do is create an entry in the registry so that windows automatically knows that the program is safe...

Ruffnekk

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 332
  • Uhm yeah...
    • View Profile
    • RuffNekk's Crypto Pages
    • Donate to Member
Re: Registry Help...
« Reply #1 on: March 12, 2007, 04:29 PM »
The easiest way is to add an entry to the registry under HKEY_CLASSES_ROOT. Just fire regedit and take a look around the defined keys and values there.

Basically you first create a subkey in HKCR that defines the extension. The keyname is a dot followed by the extension you want to associate. Once you created this key, you change the value of (default) to the name of your app or something that describes the file. Under HKCR you create another subkey with that exact same app name or description. Now your extension points to this key. Under this key you create another subkey 'Shell', which has a subkey 'Open', which has a subkey 'Command'. Here you can change (default) value to the command that must be launched when Open is chosen in the context menu or the file is double-clicked.
Regards,
RuffNekk

Programming is an art form that fights back.

Renox

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 58
    • View Profile
    • Donate to Member
Re: Registry Help...
« Reply #2 on: March 12, 2007, 04:42 PM »
is there anyway to do this programmatically so that when a person runs the program for the first time, I can have it ask them if they want to register it for future reference... That way I dont have to have the directions on how to install this somewhere for every person who ever downloads this... Thank you for your time and disregard any stupidity due to me being a young programmer!

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Donate to Member
Re: Registry Help...
« Reply #3 on: March 12, 2007, 06:30 PM »
Renox,

Are you deploying your programs via an installer/setup? Most likely that will be available as an option in your installer/setup builder. If not, what programming language and tools are you using? As you will need to do it "manually" otherwise. (There are plenty of example out in the wild you can use to base your code off of.)

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 8,069
    • View Profile
    • Donate to Member
Re: Registry Help...
« Reply #4 on: March 12, 2007, 07:14 PM »
Not a programmatic method but the simplest way you can set up or alteer a file association is to use Tools > Folder Options > File Types in Windows Explorer.

If you want to set it up so that the user doesn't have to do anything you will need to set it up as part of the installation routine.

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: Registry Help...
« Reply #5 on: March 13, 2007, 06:36 AM »
Ruffnek's way works (just fill in the API calls yourself :) ), but one word of warning: the code to do this will not run on a limited user account, but requires administrative privileges.

Now that Vista has come to enforce stuff, you really should do the association from your installer. Which, as tinjaw says, probably has an option to do this that's easier than the API calls anyway :)
- carpe noctem

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: Registry Help...
« Reply #6 on: March 13, 2007, 08:58 AM »
Inno Setup can associate a particular file extension with your application.  The Inno Setup help documentation shows you how to configure this.