1 Attachment(s)
VB6 - AppEx Class, Assists Vista Programming
With the advent of Windows Vista we find a few new requirements. While Microsoft introduced new application standards years ago few of these were enforced until the release of Vista.
It has become more important than ever to do OS version sensing now. More importantly since Vista aggressively protects many of the file paths we used to put program data and settings into, we need to do some extra work to locate the acceptable locations for such files.
AppEx makes the necessary system calls in an easy to use form. This Class module has been designed to be "dropped into" your projects and offer an immediately accessible "extension" similar to the intrinsic global App object: there is no need to explicitly create an instance of AppEx in your programs.
The methods AppEx offers are:
- AppEx.ComputerName()
- AppEx.InitCommonControls()
- AppEx.OSVersion()
- AppEx.Path()
- AppEx.PathAndSubDir()
- AppEx.UserName()
InitCommonControls() is probably familiar enough to many of you. It should be called prior to loading VB forms in order to link to the Common Controls 6.0 library. It requires an application manifest with a Common Controls 6.0 <dependency> node in order to be effective.
The OSVersion() method accepts a parameter describing the type of information desired. AppEx provides an Enum AppExOSVersion defining these.
The Path() method accepts a parameter having CSIDL values for the different folders you might want. The set is not complete but contains the most useful ones as Enum AppExPaths.
PathAndSubDir() is similar to Path() but also accepts a SubDir parameter and a ForceCreation parameter. It is used to locate and optionally create a subfolder structure beneath one of the special folders.
The attached file contains a demo project based on this Class. While there is nothing particularly clever here, AppEx makes dealing with the issues quicker by providing pre-written code for the purpose.
Re: VB6 - AppEx Class, Assists Vista Programming
Hoping to thank you later. We have a vb6 on XP application and are going crazy trying to get it to run on VISTA. As part of the install process we have to phone home to pass information to our server and get responses back (for example, "is this computer already registered on the server", Return true of false and then do something).
Getting something returned isn't happening and we think that your thread is pertinent. It is, right?????
Just a little more rope and I will have enough to really mess things up.
Re: VB6 - AppEx Class, Assists Vista Programming
great information another handy function I use in vista
Private Declare Function IsUserAnAdmin Lib "shell32" () As Long
Comes in handy when running as standard user and a part of program needs Admin to continue. I use it for program updates
Re: VB6 - AppEx Class, Assists Vista Programming
Quote:
Originally Posted by
monkeybusiness
Hoping to thank you later. We have a vb6 on XP application and are going crazy trying to get it to run on VISTA. As part of the install process we have to phone home to pass information to our server and get responses back (for example, "is this computer already registered on the server", Return true of false and then do something).
Getting something returned isn't happening and we think that your thread is pertinent. It is, right?????
No, I don't see how this Class helps with phoning home. Hopefully you found a useful answer elsewhere.
Re: VB6 - AppEx Class, Assists Vista Programming
I did some work recently on user accounts, and IsUserAnAdmin fails when UAC is turned on in Vista/7. There are a few workarounds for this, but I went with the NetUserGetInfo and having it return a USER_INFO_3 structure. When usri3_priv = USER_PRIV_ADMIN, then the user is actually an admin, regardless of the machine's current UAC status.
Re: VB6 - AppEx Class, Assists Vista Programming
Quote:
Originally Posted by
Jordan
I did some work recently on user accounts, and IsUserAnAdmin fails when UAC is turned on in Vista/7. There are a few workarounds for this, but I went with the NetUserGetInfo and having it return a USER_INFO_3 structure. When usri3_priv = USER_PRIV_ADMIN, then the user is actually an admin, regardless of the machine's current UAC status.
IsUserAnAdmin() doesn't really tell whether or not the user is a member of the Administrators group, it tells you whether the running process has administrator rights. This is generally much more important to programs than group membership.
Its purpose is to help the program decide whether or not it needs to request elevation to perform an administrative function. If it returns True you can go ahead and do what is required, otherwise you start an elevated process to perform it for you.
Re: VB6 - AppEx Class, Assists Vista Programming
I was a bit puzzled first as when I run the example program it said OSversion 5.01 and ServicePack 3, while this is Windows 7-64, but then I remembered that I run VB6IDE in XP SP3 compatibility mode ;-)
Thought I should mention it here anyway as it should account for almost everyone how (still) use VB6 and on Win7, and after some time one sort of forget about it... Nice approach anyway and may come handy to use.
Re: VB6 - AppEx Class, Assists Vista Programming
Yep, one of the appcompat shims is called "Version Lie" and that's just about all you get by marking VB6.exe with it.
I'm not sure what you feel you gain by that though... besides confusing yourself. ;)