Re: VBA / VBS to get Desktop folder string



Thank you, O Great One, for the reply.


Given that there's a completely reliable method for getting that
information

How I am supposed to know how reliable the API is, when I'm obviously too
stupid to know that I shouldn't be using enviroment variables?

From Dev's code:
' 4.00 All Microsoft® Windows® 95/Windows NT® 4.0.
' 4.70 All Microsoft® Internet Explorer 3.x.
' 4.71 All Microsoft® Internet Explorer 4.0
' 4.72 All Microsoft® Internet Explorer 4.01 and
Windows® 98
' 5.00 Shlwapi.dll Microsoft® Internet Explorer 5
' 5.00 Shell32.dll Microsoft® Windows® 2000.
' 5.80 Comctl32.dll Microsoft® Internet Explorer 5
' 5.81 Comctl32.dll Microsoft® Windows 2000

I see no references to Windows XP, Vista, nor the latest versions of
Internet Explorer (we are on 7 now, not 5), nor do I see any datestamp on the
webpage that may indicate when this API was current as of.



The Windows API calls are bulletproof
Are you saying that everyone should assume that every API written throughout
the evolution of the windows system is to remain reliable for all time
without question? If you could be so kind as to extrapolate on the subject,
because apparently I am the only poor fool on the face of this earth that
does not know how Windows maintains APIs.



Of course, there
are also lots of newer applications that set environment variables,
so they are obviously depending on them at some level.

Again, I must be the only person that was not aware of the fact that the
programmers who design these applications make use of environment variables
for no reason other than because they are imbeciles and have idea of what
they are doing. How presumptuous of me to assume otherwise...



using the registry would be
bypassing the Windows API set up for just this purpose, so I don't
know why in the world you'd do that.

I don't suppose it would have anything to do with the fact that I know
little of how API functions are written in relation to Windows Registry
values. Obviously, I should put my blind faith on the fact that every API
written will always be more secure than the Windows Registry, even if the API
was created years before my current operating system was released (along with
a compatible registry... imagine that).



Who cares?

Well, for some reason I had assumed that I might not have been the only
person to read this post and wondered about another person's experience with
environment variables across platforms. Sometimes I forget that I am the
only person here that does not know everything.


I have always seen environment variables as legacy values, there to
support older applications that might need them.

Who cares?



It's not like once you've imported Dev's code
into your app that you have to recode it every time you use it --
it's a one-time coding project

Thank you for verifying this... I was under the assumption that I needed to
put this into a separate module for every time I wanted to call the function.
With your obvious God-like knowledge, I should have known that you would be
able to save me many many modules of code. Is it permittable to delete those
lines in green with the little apostrophe thingies at the beginning also?





I come here, like many others, to gain (and make an attempt to spread)
knowledge and awareness. And, like many others, I would prefer not to be
treated as ignorant child due to the questions I ask. Anyone who takes
everything at face value without asking questions in doubt is bound to suffer
severe consequences at some point or another, and it is my nature to not want
to be a part of this unfortunate group of people.

Right, wrong, or indifferent, perhaps you be just a teeeeeny bit less
conceded about it?


--
Jack Leach
www.tristatemachine.com

- "A designer knows he has reached perfection not when there is nothing left
to add, but when there is nothing left to take away." - Antoine De Saint
Exupery


"David W. Fenton" wrote:

=?Utf-8?B?ZHltb25kamFjaw==?= <dymondjack at hot mail dot com> wrote
in news:1A75B53C-95ED-4EFD-961C-4816D53EE5F5@xxxxxxxxxxxxx:

It's not a good idea to depend on environment variables, as those
can be altered easily to something invalid.

I can certainly agree that most of the environ vars shouldn't be
relied upon, but I've always considered the "core" ones to be
stable (USERNAME, COMPUTERNAME, WINDIR, TEMP, TMP etc.)

Given that there's a completely reliable method for getting that
information, why run the risk that some other program running in the
same environment as your Access app has changed the environment
variables? All you have to do to see how easy it is to change is to
go to the properties of My Computer, click the ADVANCED tab, click
on the ENVIRONMENT VARIABLES and then add in a new value for any
environment variable you like. This will override whatever had
previously been the value. If you can do this in the user interface,
your users can, and so can applications.

Now, I don't know why anyone *would* do those things, but the point
of writing an application is to make it bulletproof wherever
possible, not to gamble on someone not doing something that you know
they could do but can't forecast *why* they'd do it. The Windows API
calls are bulletproof and I don't see any reason why one would not
choose to use those. It's not like once you've imported Dev's code
into your app that you have to recode it every time you use it --
it's a one-time coding project, and from then on, it's no harder
than using Environ().

I don't post this as an argument, but rather as a question. I've
been of the impression that windows and just about every program
you install uses these 'core' variables, and therefore assumed
that changing them would result in serious errors throughout the
system. Obviously, I've never tried changing WINDIR to see what
happens :p

I have always seen environment variables as legacy values, there to
support older applications that might need them. Of course, there
are also lots of newer applications that set environment variables,
so they are obviously depending on them at some level.

But just because other developers jump off the cliff...

Unfortunately, I know little about how windows and other programs
stores information such as this. I see these vars used numberous
times in various batch files (both system created and user
created).

That's because batch files don't have access to Windows APIs, and
*have* to depend on them. The batch files run on the assumption that
the environment variables are correct at the time the command prompt
session they run in was created. If they are incorrect, then the
batch files will break, and there's no way for a batch file to fix
that.

Are the actual values that the OS and its apps use stored in the
registry as opposed to envrion vars? In which case, I should be
going to the reg for the values (or wherever they may be
stored...)

Certain values for which environment variables are created are going
to be stored in the registry, but using the registry would be
bypassing the Windows API set up for just this purpose, so I don't
know why in the world you'd do that.

It may also be that certain values are *not* stored in the registry,
so that might be an incomplete solution, anyway.

Again, there's a Windows API defined for this purpose and it's
usable in Access. There seems to me to be no justification
whatsoever for not using that.

If anyone could clarify, that would be great. I've always
wondered about this.

For the record, I've gone through these environ vars on Win2000,
XP and Vista (gotta love consistancy with OS versions in the
workplace) and have found that the var names that I do use are
consistent between these three OS versions.

Who cares? The point is that the Windows API is a better way to get
the information, and given that Access can use API calls, there's no
reason not to use the most reliable method for getting that
information.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/

.



Relevant Pages

  • Re: VBA / VBS to get Desktop folder string
    ... How I am supposed to know how reliable the API is, ... programmers who design these applications make use of environment variables ... bypassing the Windows API set up for just this purpose, ... written will always be more secure than the Windows Registry, ...
    (microsoft.public.access.modulesdaovba)
  • Re: Log in form
    ... It's trivial to reset environment variables. ... use the API approach illustrated in ... Doug Steele, Microsoft Access MVP ... >> form field. ...
    (microsoft.public.access.forms)
  • Re: set environment variables
    ... > Is there any api call? ... environment variables for the current user are contained ... -Software Consultant (Embedded systems and Real Time Controls) ...
    (microsoft.public.win2000.developer)
  • Re: environment variables
    ... The Environfunction returns whatever environment variables are defined. ... Doug Steele, Microsoft Access MVP ... for environ) - (Doug, the API is good, but I need the environ$ list.) ...
    (microsoft.public.access.modulesdaovba)
  • Re: Most elegant way to read to allocatable array?
    ... software (e.g. Windows API). ... It would be nice to have an API that can access some of the internal information stored by the run time or OS and to be able to coordinate IO across DLLS ... I have seen cases where I wanted to use 2 3rd party libraries, ... That may be because every handle I've been exposed to is simply an integer ID, similar to an LFN. ...
    (comp.lang.fortran)