For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > November 2005 > Windows Global Variable









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Windows Global Variable
The Merg

2005-11-23, 6:55 pm

Okay, I know it's simple, but I'm having a brain fart. I'm using VB6 on XP-SP2. I want to set the Windows Global Variable of %MYDOCDIR% to a string variable in my app, yet I cannot seem to remember how to refer to the Global Variable in my code. Thanks in advance.

- The Merg

--
Today's problems don't worry me,
I haven't solved yesterday's yet.
Ralph

2005-11-23, 6:55 pm


"The Merg" <howard_mergler@NOSPAM.themerg.net> wrote in message
news:ewQEkqD8FHA.3200@TK2MSFTNGP11.phx.gbl...
Okay, I know it's simple, but I'm having a brain fart. I'm using VB6 on
XP-SP2. I want to set the Windows Global Variable of %MYDOCDIR% to a string
variable in my app, yet I cannot seem to remember how to refer to the Global
Variable in my code. Thanks in advance.

- The Merg

--
Today's problems don't worry me,
I haven't solved yesterday's yet.

==================================

Environ$()

-ralph


Bob Butler

2005-11-23, 6:55 pm

"The Merg" <howard_mergler@NOSPAM.themerg.net> wrote in message
news:ewQEkqD8FHA.3200@TK2MSFTNGP11.phx.gbl
> Okay, I know it's simple, but I'm having a brain fart. I'm using VB6
> on XP-SP2. I want to set the Windows Global Variable of %MYDOCDIR% to
> a string variable in my app, yet I cannot seem to remember how to
> refer to the Global Variable in my code. Thanks in advance.


I don't have XP so if that's a new environment variable then
Environ$("MYDOCDIR") should work. If not, then search groups.google.com for
examples using the SHGetSpecialFolderLocation API call.

--
Reply to the group so all can participate
VB.Net: "Fool me once..."

MikeD

2005-11-23, 6:55 pm


"The Merg" <howard_mergler@NOSPAM.themerg.net> wrote in message
news:ewQEkqD8FHA.3200@TK2MSFTNGP11.phx.gbl...
Okay, I know it's simple, but I'm having a brain fart. I'm using VB6 on
XP-SP2. I want to set the Windows Global Variable of %MYDOCDIR% to a string
variable in my app, yet I cannot seem to remember how to refer to the Global
Variable in my code. Thanks in advance.



You can try the SetEnvironmentVariable Win32API function, but I doubt you'll
get the results you want. The new value you set is only going to be visible
to your app. Can you imagine the problems there'd be if an app could
arbitrarily change system environment variables?

Also, please don't post using HTML. Use plain text.

--
Mike
Microsoft MVP Visual Basic


Paul Clement

2005-11-23, 6:55 pm

On Wed, 23 Nov 2005 09:33:49 -0500, "The Merg" <howard_mergler@NOSPAM.themerg.net> wrote:

¤ Okay, I know it's simple, but I'm having a brain fart. I'm using VB6 on XP-SP2. I want to set the Windows Global Variable of %MYDOCDIR% to a string variable in my app, yet I cannot seem to remember how to refer to the Global Variable in my code. Thanks
in advance.
¤

Well if you're referring to system wide environment variables (not application local), setting them
is problematic and requires different implementations depending upon the version of the OS. I would
use another method such as a configuration file or the Registry.


Paul
~~~~
Microsoft MVP (Visual Basic)
The Merg

2005-11-25, 6:55 pm

I think you hit it on the nail as to what I was looking for. I did notice that VB has the Environ function and the Environ$ function listed, but the explanation of both is the same. Are you aware of any differences?

Thanks,
Merg

--
Today's problems don't worry me,
I haven't solved yesterday's yet.

"Bob Butler" <tiredofit@nospam.com> wrote in message news:urtZytD8FHA.3416@TK2MSFTNGP15.phx.gbl...
> "The Merg" <howard_mergler@NOSPAM.themerg.net> wrote in message
> news:ewQEkqD8FHA.3200@TK2MSFTNGP11.phx.gbl
>
> I don't have XP so if that's a new environment variable then
> Environ$("MYDOCDIR") should work. If not, then search groups.google.com for
> examples using the SHGetSpecialFolderLocation API call.
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."
>

Rick Rothstein [MVP - Visual Basic]

2005-11-25, 6:55 pm

> I think you hit it on the nail as to what I was
> looking for. I did notice that VB has the Environ
> function and the Environ$ function listed, but the
> explanation of both is the same. Are you aware
> of any differences?


The one with the $ sign returns a pure String data type value, the one
without the $ sign returns a Variant data type value with a sub-type
of String. For use in String manipulations, the one with the $ sign is
marginally faster.

Rick


The Merg

2005-11-25, 6:55 pm

Thanks!

- Merg

--
Today's problems don't worry me,
I haven't solved yesterday's yet.

"Rick Rothstein [MVP - Visual Basic]" <rickNOSPAMnews@NOSPAMcomcast.net> wrote in message news:%23umJ8wd8FHA.3504@TK2MSFTNGP11.phx.gbl...
>
> The one with the $ sign returns a pure String data type value, the one
> without the $ sign returns a Variant data type value with a sub-type
> of String. For use in String manipulations, the one with the $ sign is
> marginally faster.
>
> Rick
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com