Author Topic: 2011+ | Custom System Variables  (Read 4752 times)

0 Members and 1 Guest are viewing this topic.

BlackBox

  • King Gator
  • Posts: 3770
2011+ | Custom System Variables
« on: May 23, 2012, 01:08:25 PM »
I know that in LISP one can simply declare a global variable, or use either Get/SetEnv, or vl-registry-write/read... or in .NET since there is no global variable, one can simply store a 'parameters' Object to Application.DocumentManager.MdiActiveDocument.UserData Hashtable (I think I got the Namespace right?), but how does one create their own custom system variable(s)?

I've read Kean's article , where toward the end he mentions that in 2011 and newer, you can use a similar .REG file to create your own system variables.

Unfortunately, at present, permissions to HKLM hive is a problem for me. I've put in a request to IT, but it is unlikely to be granted.

I noticed that HKCU hive has a few Variables folders as well, but limited testing has been unsuccessful. Being able to create custom system variable(s) would prove useful for both LISP & .NET initiatives.

TIA
"How we think determines what we do, and what we do determines what we get."

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: 2011+ | Custom System Variables
« Reply #1 on: May 23, 2012, 01:42:45 PM »
Doing some searches, it appears that you can't even do this using ObjectARX, never mind DotNet/Lsp. Granted I've only done about 30min of research, so perhaps there's some way of hacking a sysvar into life.

I'd think it "should"be possible, since I can imagine a dictionary holding the sysvars (their names being the key) and having a object to refer to where the var is saved (dwg / reg / volatile). I'm sure adesk didn't simply hard-code all sysvars. ... actually I hope  :ugly:
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

BlackBox

  • King Gator
  • Posts: 3770
Re: 2011+ | Custom System Variables
« Reply #2 on: May 23, 2012, 01:46:27 PM »
Perhaps this will better illustrate:

"How we think determines what we do, and what we do determines what we get."

Jeff H

  • Needs a day job
  • Posts: 6150
Re: 2011+ | Custom System Variables
« Reply #3 on: May 23, 2012, 01:48:52 PM »
Take a look at Variable class in docs.
 
Tony T has a example floating around and
http://www.theswamp.org/index.php?topic=40774.msg460505#msg460505

BlackBox

  • King Gator
  • Posts: 3770
Re: 2011+ | Custom System Variables
« Reply #4 on: May 23, 2012, 01:50:54 PM »
What bothers me, is that these Keys are also available under HKCU at the version, and profile levels:
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3770
Re: 2011+ | Custom System Variables
« Reply #5 on: May 23, 2012, 01:59:27 PM »
Take a look at Variable class in docs.
 
Tony T has a example floating around and
http://www.theswamp.org/index.php?topic=40774.msg460505#msg460505

I haven't seen Tony's example (yet - I'll look for it after work, oh crap, second job tonight!), but this snippet from Gile should allow me to code a LispFunction Method:

Code - C#: [Select]
  1.  
  2. // snip
  3.                //hive = Registry.LocalMachine;
  4.                RegistryKey hive = Registry.LocalMachine;
  5.                //
  6.                using (RegistryKey ack = hive.OpenSubKey(prodk, true))
  7.                {
  8.                    // Create the sysvar definition key
  9.                    using (RegistryKey vark = ack.OpenSubKey("Variables", true))
  10.                    {
  11.                        if (vark.GetSubKeyNames().Contains("LAYLOCKSEL"))
  12.                        {
  13.                            MessageBox.Show("LAYLOCKSEL is already installed", "LAYLOCKSEL");
  14.                            return;
  15.                        }
  16.                        else
  17.                        {
  18.                            using (RegistryKey rk = vark.CreateSubKey("LAYLOCKSEL"))
  19.                            {
  20.                                rk.SetValue("", 0, RegistryValueKind.String);
  21.                                rk.SetValue("LowerBound", 0, RegistryValueKind.DWord);
  22.                                rk.SetValue("PrimaryType", 5003, RegistryValueKind.DWord);
  23.                                rk.SetValue("StorageType", 1, RegistryValueKind.DWord);
  24.                                rk.SetValue("UpperBound", 1, RegistryValueKind.DWord);
  25.                            }
  26.                        }
  27.                    }
  28.  
  29. // snip
  30.  

I am somewhat shocked though, that (according to what I read quickly), all one must do is include a manifest in order to avoid permissions issues... Bloody brilliant!  :lmao:
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3770
Re: 2011+ | Custom System Variables
« Reply #6 on: May 23, 2012, 02:12:05 PM »
I 'spose my next question is, that if the HKLM\*\Variables is for registering system variables, then does anyone know what are the HKCU\*\Variables Keys for (at the Version and Profile level)?  :?
"How we think determines what we do, and what we do determines what we get."

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: 2011+ | Custom System Variables
« Reply #7 on: May 23, 2012, 03:20:59 PM »
Hi,

I had a private discussion with Kean about custom sysvar ceation, here's his reply:
"Yes, my understanding is that writing to HKLM is currently required for sysvar registration, whether you use an EXE, an MSI with elevated privileges or even a REG file to create it."

IMO,using  these custom sysvar isn't so intersting with LISP as with .NET where it's possible to handle the Variable.Changing and Variable.Changed events.
Speaking English as a French Frog

BlackBox

  • King Gator
  • Posts: 3770
Re: 2011+ | Custom System Variables
« Reply #8 on: May 23, 2012, 03:30:57 PM »
Hi,

I had a private discussion with Kean about custom sysvar ceation, here's his reply:
"Yes, my understanding is that writing to HKLM is currently required for sysvar registration, whether you use an EXE, an MSI with elevated privileges or even a REG file to create it."

IMO,using  these custom sysvar isn't so intersting with LISP as with .NET where it's possible to handle the Variable.Changing and Variable.Changed events.

Gile, thanks for your reply. I continue to learn much from your (sometimes even old) posts.

My thought is to have some custom system variables for our internal apps, that would be accessible via getvar/setvar, and vlr-sysvar-reactor as applicable. I am personally starting to do a lot of C#.NET development, but sadly, I am one in a handful that is even interested in .NET development at my company. So whatever I do, needs to be accessible via LISP as well.

My intent is to code some LispFunction Methods to allow users to create and store custom system variables of their own as well. The point being to encourage, and simplify the process of, others creating efficiency initiatives.
"How we think determines what we do, and what we do determines what we get."

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: 2011+ | Custom System Variables
« Reply #9 on: November 08, 2012, 01:44:52 AM »
2 RenderMan
As variant for problem's solving (about HKLM): IT can to change ACL only for this registry key - to add necessary permissions for your windows profile.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: 2011+ | Custom System Variables
« Reply #10 on: November 08, 2012, 01:54:09 AM »
Where can I read about 'PrimaryType' parameter? Which values is allowed?

BlackBox

  • King Gator
  • Posts: 3770
Re: 2011+ | Custom System Variables
« Reply #11 on: November 08, 2012, 08:52:21 AM »
2 RenderMan
As variant for problem's solving (about HKLM): IT can to change ACL only for this registry key - to add necessary permissions for your windows profile.

Thanks for the suggestion, Andrey.

I actually did request the necessary permissions for HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\* segment of the HKLM hive, and that request was denied.
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3770
Re: 2011+ | Custom System Variables
« Reply #12 on: November 08, 2012, 08:53:56 AM »
Where can I read about 'PrimaryType' parameter? Which values is allowed?

Perhaps this related post will help.
"How we think determines what we do, and what we do determines what we get."