Results 1 to 5 of 5

Thread: Hkey_local_machine

  1. #1
    Join Date
    Aug 2003
    Location
    Wisconsin
    Posts
    60

    Hkey_local_machine

    Hi,

    it is my understanding that when setting the product version through InstallShield, the registry gets written out to:

    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall

    I am using C# and need to access the ProductVersion. I have tried the following in my code.

    RegistryKey rk =
    Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", false);

    // Get the data from a specified item in the key.
    String s = (String)rk.GetValue("CurrentVersion");

    My problem is accessing the actual property: INSTALLPROPERTY_VERSION
    which stores the version number...

    Any ideas??

    Thanks
    Nick

  2. #2
    Join Date
    Dec 2003
    Location
    Bangalore, Karnataka, India
    Posts
    136
    Hi Nick,

    If you are comfortable with COM then you can use the Windows Installer automation interface.

    You need to include the msi.dll ( Microsoft Windows Installer Automation Support) in the project. Then you can create the Installer object. Once the object is created you can use the OpenPackage() function. Read the Windows Installer help library articles on automation interface. It would save a lot of trouble fiddling with the registry.

    Hope this helps

  3. #3
    Join Date
    Aug 2003
    Location
    Wisconsin
    Posts
    60
    Thank you for your reply. I have done some research regarding the automation interface. However, it seems as if I can only use that in my InstallShield project and not my actual application. I can set the version for InstallShield via General Information. Then when I install the application using InstallShield, it provides the version number in Add/Remove Programs in the Control Panel. I want to use this version for my application version in the Help//About box. I know the information has to be written to a registry somewhere, I'm just not sure how to access it.

    Also, the automation interface appears to be a helpful tool....
    there are many methods that can be used to find out information, but only on the InstallShield side.

    Thanks,
    Nick

  4. #4
    Join Date
    Dec 2003
    Location
    Bangalore, Karnataka, India
    Posts
    136
    Hi Nick,

    Windows Installer automation interface can be used even outside Installation context. Its a pretty helpful api. You can copy and paste the VBScript code below in a text file and save it with a .vbs extension. Double click on the file to display a version of the product with a specified GUID. Do not forget to set the value of the MyProductCode variable.

    'Begin Code
    dim MyProductCode
    MyProductCode="" 'Your product code goes within the quotes
    set InstallerObj=CreateObject("WindowsInstaller.Installer")
    InstallerObj.UILevel=2
    'Be Silent
    set SessionObj=InstallerObj.OpenDatabase(MyProductCode)
    msgbox SessionObj.ProductProperty("ProductCode")
    'end code

    Hope this gives you an idea. There is a book called VB/VBA developers Guide to Windows Installer by Mike Gunderloy. That is a good resource if you want to get rolling with Windows Installer. Also the Windows Installer SDK includes a lot of sample VBScripts. You can download the Windows Installer SDK from microsoft's platform SDK site.

  5. #5
    Join Date
    Aug 2003
    Location
    Wisconsin
    Posts
    60
    Thanks......

    I will definitely do some more research on the automation interface. I was unaware that you could use this interface outside of installation. (still a newbie) Also, thanks for the reference to the book, it will probably be my next investment.

    For the meantime, in case anyone was wondering, I found out how to set the registry in InstallShield. I didn't realize that InstallShield didn't write anything out to the target computer's registry automatically. So what I did, is created a text registy and added to Software\"My Product". Then when I install, the registry is written. Now in the code of my project I use the following statements. C#

    // Create a RegistryKey, which will access the
    //HKEY_CURRENT_USER key in the registry of this machine.

    //aString for the path to the values in the registry
    string aRegString = "Software\\AccelSurvey";

    //Assign the registry key to the local machine
    RegistryKey aRegKey = Registry.LocalMachine.OpenSubKey(aRegString);

    string aVersion = (string)aRegKey.GetValue("Version");

    //Close the Registry Key
    aRegKey.Close();
    //Assign the version number to a label
    lblVersion.Text = aVersion;


    Thanks again for your help mr_anderson

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •