How to get the bricscad installation directory

Hi, all. I'm a newer to use the bricsCAD. I wrote a program to call up the [bricscad.exe] on any other windows PC which installed the bricsCAD. I wonder how could I got the directory of [bricscad.exe] . Thanks a lot!

Comments

  • Not sure what language you are working in but the best bet is going to be getting the install directory out of windows registry
  • Good Day and thank you for your reply. I used BricsCAD on windows and write a windows app use C#, on Visual Studio 2022. I tried the windows registry, and I found the Bricsys' installation directory as below.

    when I try to read from registry, I got a null value.

    Then, I tried to read the value from "SOFTWARE", but I got the message said I have no authorized.

    How should I read the keys and values from \HKEY_LOCAL_MACHINE\SOFTWARE\, thank you very much!
    * BTW, I starred the Visual Studio in a Administrator priority.
  • In lisp

    (vl-registry-read (strcat "\\HKEY_LOCAL_MACHINE\\" (vlax-product-key)) "installDir")
  • In .NET, you have to watch out for the difference between the 32bit and the 64bit hive in the registry.

    If you don't account for this, you may get nothing, or an error attempting to retrieve a value. Yes, true, BricsCAD (and AutoCAD) typically end up in the 64bit hive these days, but the hives are still a thing.

    Below is code I'm using to manage it, I've split it out from my code, so it should be self-contained.

    It's probably more verbose that I might otherwise like, but seeing the returned values during debug was useful and I've left it be.

    Note that it will return all installed versions as long as the "InstallDir" value can be retrieved.

    I get all the installed versions because I'm looking to create shortcuts for each, that point at our customisation. You could simplify the code if you don't have this requirement.

    If nothing's installed, you'll just get a dictionary with no items.

    The code is also running as "SYSTEM" that ensures access permissions to HKEY_LOCAL_MACHINE.

    using Microsoft.Win32; using System.Collections.Generic; namespace CreateShortcut { internal class BricsCADStuff { static string bricsRoot = @"SOFTWARE\Bricsys\Bricscad"; static Dictionary<string, string> GetBricsCADInstallDirectories() { RegistryKey localMach32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32), localMach64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); Dictionary<string, string> result = new Dictionary<string, string>(); if (localMach32.OpenSubKey(bricsRoot) != null) { RegistryKey bricsCADKey = localMach32.OpenSubKey(bricsRoot); foreach (string appName in bricsCADKey.GetSubKeyNames()) { RegistryKey appKey = bricsCADKey.OpenSubKey(appName); string lang = appKey.GetValue("CURVER").ToString(); RegistryKey langKey = appKey.OpenSubKey(lang); string insDir = langKey.GetValue("InstallDir").ToString(); result.Add(appName, insDir); } } else if (localMach64.OpenSubKey(bricsRoot) != null) { RegistryKey bricsCADKey = localMach64.OpenSubKey(bricsRoot); foreach (string appName in bricsCADKey.GetSubKeyNames()) { RegistryKey appKey = bricsCADKey.OpenSubKey(appName); string lang = appKey.GetValue("CURVER").ToString(); RegistryKey langKey = appKey.OpenSubKey(lang); string insDir = langKey.GetValue("InstallDir").ToString(); result.Add(appName, insDir); } } return result; } } }

  • Sorry that was supposed to be a code block in my reply, but has posted as a complete shambles. It certainly didn't preview like a block of disorganised text. Sigh!

    Here's the raw text instead. Preview loses all the indenting, even though they're spaces.

    using Microsoft.Win32;
    using System.Collections.Generic;

    namespace CreateShortcut
    {
    internal class CodeIsolation
    {
    static string bricsRoot = @SOFTWARE\Bricsys\Bricscad;

    static Dictionary GetBricsCADInstallDirectories()
    {
    RegistryKey
    localMach32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32),
    localMach64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);

    Dictionary result = new Dictionary();

    if (localMach32.OpenSubKey(bricsRoot) != null)
    {
    RegistryKey bricsCADKey = localMach32.OpenSubKey(bricsRoot);

    foreach (string appName in bricsCADKey.GetSubKeyNames())
    {
    RegistryKey appKey = bricsCADKey.OpenSubKey(appName);
    string lang = appKey.GetValue("CURVER").ToString();
    RegistryKey langKey = appKey.OpenSubKey(lang);
    string insDir = langKey.GetValue("InstallDir").ToString();
    result.Add(appName, insDir);
    }
    }
    else if (localMach64.OpenSubKey(bricsRoot) != null)
    {
    RegistryKey bricsCADKey = localMach64.OpenSubKey(bricsRoot);

    foreach (string appName in bricsCADKey.GetSubKeyNames())
    {
    RegistryKey appKey = bricsCADKey.OpenSubKey(appName);
    string lang = appKey.GetValue("CURVER").ToString();
    RegistryKey langKey = appKey.OpenSubKey(lang);
    string insDir = langKey.GetValue("InstallDir").ToString();
    result.Add(appName, insDir);
    }
    }

    return result;
    }
    }
    }
  • ALANH said:

    In lisp

    (vl-registry-read (strcat "\\HKEY_LOCAL_MACHINE\\" (vlax-product-key)) "installDir")

    You give me another way of solution. Thank you very much for your warmly help!
  • Sorry that was supposed to be a code block in my reply, but has posted as a complete shambles. It certainly didn't preview like a block of disorganised text. Sigh!

    Here's the raw text instead. Preview loses all the indenting, even though they're spaces.

    using Microsoft.Win32;
    using System.Collections.Generic;

    namespace CreateShortcut
    {
    internal class CodeIsolation
    {
    static string bricsRoot = @SOFTWARE\Bricsys\Bricscad;

    static Dictionary GetBricsCADInstallDirectories()
    {
    RegistryKey
    localMach32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32),
    localMach64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);

    Dictionary result = new Dictionary();

    if (localMach32.OpenSubKey(bricsRoot) != null)
    {
    RegistryKey bricsCADKey = localMach32.OpenSubKey(bricsRoot);

    foreach (string appName in bricsCADKey.GetSubKeyNames())
    {
    RegistryKey appKey = bricsCADKey.OpenSubKey(appName);
    string lang = appKey.GetValue("CURVER").ToString();
    RegistryKey langKey = appKey.OpenSubKey(lang);
    string insDir = langKey.GetValue("InstallDir").ToString();
    result.Add(appName, insDir);
    }
    }
    else if (localMach64.OpenSubKey(bricsRoot) != null)
    {
    RegistryKey bricsCADKey = localMach64.OpenSubKey(bricsRoot);

    foreach (string appName in bricsCADKey.GetSubKeyNames())
    {
    RegistryKey appKey = bricsCADKey.OpenSubKey(appName);
    string lang = appKey.GetValue("CURVER").ToString();
    RegistryKey langKey = appKey.OpenSubKey(lang);
    string insDir = langKey.GetValue("InstallDir").ToString();
    result.Add(appName, insDir);
    }
    }

    return result;
    }
    }
    }

    It was really very help and teach me a lot! Thank you sincerely!