Making Your Application Vista / Windows 7 / Windows 8 Compliant

Started by Randem, September 22, 2014, 07:26:56 PM

Previous topic - Next topic

Randem

         Vista / Windows 7 / Windows 8  Compliant, what does it really mean? When installing on Vista / Windows 7 / Windows 8, it is very different than installing on previous Windows versions. One main difference is writing to the registry. Many locations are basically off limits for legacy  or badly written applications and Vista will perform "Registry Virtualization" which means that some registry information that used to go to the registry will now go to your profile on disk. Another change is that you should not install your app to the "Program Files" folder unless it will not write any information in the installed location. If it does you will need supervisory privileges to do so. It is best to make your application as clean as possible and not require supervisory privileges at all.

         The most common area to install your non-compliant app (Apps that cannot be changed) or a third party pre-packaged legacy apps (apps that have the data files that the app writes to in the same folder as the exe) in Vista is "C:\Users\Public\YourAppName"  There are no restrictions to your app in this locations. This is especially true if your app writes to the installed location and you cannot move the database or file it writes to. Installing in this location; you can allow your program to write to the file without having Administrator privileges; however you will lose Vista's protection for your app from program modifications or deletions (virus, malware, hacking or just plain stupidity). An application should never run "As Administrator" if you can help it.

          If your apps run in XP under a limited users account they should run in Vista under the same. Strange as it might seem, I have apps that run just fine in a Limited Users account in Vista but not in a Limited Users account on XP (due to virtualization). It would seem that some software applications attempts to change some off-limit registry location and therefore the app won't work. Many times the main reason a properly constructed VB app won't work under a Limited Users account is a permissions restriction on the HKLM\Software\Classes\TypeLib key. The problem is that the user does not have read access rights and therefore the app cannot instantiate objects that have CSLID's that reside there. A simple fix is to change the permissions under an administrator account for Read rights then everything will work just fine under the limited users account.

         I have read on the internet in various forums that the All Users folder can't be used. These people have no idea of what they are talking about!!! Therefore it would not be a brilliant idea to listen to their opinions on how to properly install an application; they truly have no idea or very limited knowledge in this area. The All Users folder is writable, you just need to create a folder in it then you can write you data into that folder. What are these people thinking??? If everyone wrote their data to the All Users folder without their own folder everyone would be over writing over other apps data and files with the same name. Such idiocies...

Reference: http://support.microsoft.com/kb/296114

   
Here are some tips to help you create a Vista compliant app
     
          If you have files in the installation folder (C:\Program Files\YourAppName) that you read and do not write to. Open the file with read only access. Opening files with write access in a protected folder is asking for trouble with unexplained or unexpected application crashes for unhandled errors. You should get the application data path using a system API, create a folder then place your data there. You will also need to change the file locations in your app to point to these locations where you access the data that needs to be written to disk.

          Do not access the registry any more than you need to and if you need to make sure it is not a protected part of the registry (for writing). Most of the time it is easy to tell if the location you want to access is protected. Create a limited users account then log onto it, open RegEdit (Start->Run, then type in Regedit) then go to the key where you want to write and look at the permissions for the user "Everyone" (Right click on the key). If you see the key in the Administrator account and don't see it in the Limited Users account, you definitely cannot use that key. If you find the key in the Limited Users account and you check the permissions and there is no user "everyone" or the user "everyone" does not have at least "Read" privileges then you can not use that registry key at all. Remember that if you do not have privileges to any level of the registry key above your key you will not have rights to that key. So if you don't have "Write" privileges you cannot update that key and attempting to write to it will give you a need for "Administrator Privileges". These few things alone will help you make a Vista compliant application and keep you from cursing your new operating system. Well, sometimes...

Making Your Application "Limited User" Compliant