Results 1 to 9 of 9

Thread: VB6 - AppEx Class, Assists Vista Programming

  1. #1

    Thread Starter
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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.
    Attached Files Attached Files

  2. #2
    Member
    Join Date
    Feb 2009
    Posts
    35

    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.

  3. #3
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    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
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  4. #4

    Thread Starter
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: VB6 - AppEx Class, Assists Vista Programming

    Quote Originally Posted by monkeybusiness View Post
    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.

  5. #5

    Thread Starter
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    AppEx Evolution

    People seem to need this more than ever before now that the timid (or gullible) have Windows 7 instead of the "scary" Vista. That and enough time has passed that people have finally replaced XP-era computers and gotten Windows 7 on them.

    Ah well.

    In any case I thought I ought to post a more recent version of AppEx. No major bug fixes, mostly changes over time to improve usability for my own programs. Name changes, general cleanup, and so on - nothing big has changed.

    Names were shortened in many cases, and some things are now Properties rather than Methods.

    Now AppEx offers these Properties:
    • Computer As String
    • IDEMode As Boolean
    • IsAdmin As Boolean
    • OSVersion(VersionData As VersionDataType) As Variant
    • Present(FileOrFolder As String) As Boolean
    • User As String

    Some members were kept as Methods because they might perform an action or otherwise aren't really Properties:
    • InitCC
    • Path(PathId As PathIdType) As String
    • PathSubdir(PathId As PathIdType, SubDir As String) As String *

    * Requires XP or later!
    The Methods also have a pair of optional parameters that can almost always be left at the defaults.

    Several Enums used here are renamed along with their individual values.


    In case it isn't clear, PathSubdir() is generally more useful than Path(). Almost always when you need to use a Special Folder you need a subdirectory beaneath it rather than the Folder itself. PathSubdir() wraps this in a neat package for you, as well as creating the full subfolder path for you if it doesn't exist.
    Attached Files Attached Files
    Last edited by dilettante; Jan 3rd, 2011 at 02:17 PM.

  6. #6
    Junior Member
    Join Date
    Apr 1999
    Location
    Tampa, FL
    Posts
    23

    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.

  7. #7

    Thread Starter
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: VB6 - AppEx Class, Assists Vista Programming

    Quote Originally Posted by Jordan View Post
    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.

  8. #8
    Addicted Member
    Join Date
    Jun 2010
    Posts
    208

    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.

  9. #9

    Thread Starter
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width