Link to home
Start Free TrialLog in
Avatar of sendtojp
sendtojp

asked on

Variables with "All of Windows" Scope

I was wondering if it is possible to create code for Variables that will last for any Application during a session of Windows.

Example:

I open CountApples.exe which Apples=120
I close CountApples.exe

I open InventoryList.exe which prints Apples=120

SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sendtojp
sendtojp

ASKER

I forget the what 'Global' scope is.

How would you store it in Registry.

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is there a 'Plain Vanilla' subroutine with a few lines of code to gain a quick understanding.  I spppose you can use Registry to simulate a Variable.
I will check back in the morning (it's 0437 here), I have to goto bed.
Dhaest,

Do you have I 'Plain Vanilla'  (aka 'Hello World' Example).  I have accessed DLL's before but never have I written to the Registry.  You can use above Apple example or equalvant.  I will also raise the point and give you an 'A' grade.

Thank You your help,

-JP
That's   ...for your help opps
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can you explain the Arguments of SaveSetting, I checked it in MSDN it assumes you know the Registry.


SaveSetting appname, section, key, setting

When this is done, I will raise the points and give some to Dhaest and Ark.

Thanks for both your help.

-JP




Hi
Get/Save settings works with HKEY_CURRENT_USER\Software\VB and VBA Program Settings registry key.
Arguments:
appname - string - subkey under above key. Usually set to App.EXE name, though it can be any unique string
section    - string - subkey under "appname" subkey. Any string (unique) you want.
key         - string - subkey under "section" subkey. Any string (unique) you want. Usualy sets to variable name.
setting    - string - registry value of "key" subkey. Usually sets to variable value.

In my sample above:
appname = MyApp
section = GlobalVar
key = "Apple"
setting = 240

So, my sample above use a subkey(s) (create one if it doesn't exist):
HKEY_CURRENT_USER\Software\VB and VBA Program Settings\MyApp\GlobalVar\XXXXX
where XXXXX is your variable(s) name(s) ("Apple" in sample) and set it (they) value(s) to YYYYYY (240 in a sample).