This article discusses file and registry virtualization in Vista and how this may affect Revolution developers.
One of the design goals of Windows Vista was security, and for this reason an array of new technologies is built into the operating system. Virtualization is one of these technologies, and we consider here file and registry virtualization.
File virtualization is a technology that is intended to provide application compatibility accross Windows Vista. In Windows Vista even administrator accounts do not have default write access to certain system-wide areas such as Program Files. This means that most programs will not have access to Program Files even though some require it to function. For this Vista provides file virtualization, which is a completely opaque method of allowing a write to Program Files but instead of writing to the actual Program Files it writes to a Virtual Store, which is nothing more than a different (user-based) location in the file system.
To see this in action, we can try the following code in Revolution:
local tFile
put merge("[[specialFolderPath(0x0026)]]/test.txt") into tFile
open file tFile for text write
write "foobar" to file tFile
close file tFile
On this particular Vista machine, the specialFolderPath returns "C:/Program Files" for the 0x0026 argument, so we expect a file "test.txt" to be located there. However, this is not the case. Revolution does not have default write permission to Program Files, and thus Vista has (invisibly) redirected the file operations to the virtual store. The test.txt file can actually be found in C:\Users\\AppData\Local\VirtualStore (notice that AppData is a hidden folder).
If we run Revolution instead as adminstrator (for example by right-clicking on the executable, and selecting "Run as administrator") then the file will end up in the real Program Files.
Some pitfalls one should be aware of:
Analogous to file virtualization, Vista also provides registry virtualization. When writing to the Registry, to HKEY_LOCAL_MACHINE\SOFTWARE, any writes that are not allowed due to inadequate permissions are redirected to HKEY_CLASSES_ROOT\VirtualStore\MACHINE\SOFTWARE.
To illustrate this let's try and set a registry key in Revolution (again, we are using an adiminstrator account, but Revolution runs with default permissions).
get setRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\RevTest\testkey", "foobar");
We can use "regedit" to inspect the registry. Indeed, we can find no such value HKEY_LOCAL_MACHINE\SOFTWARE\RevTest\testkey in the registry. Instead, we can find the registry key virtualized:
As they say, knowledge is power. If you bear these things in mind when writing your software for Vista, you should avoid the pitfalls and enjoy smooth application creation with added security, using Revolution 2.8 to create Vista compatible programs.
Our thanks to Ken Ray for drawing these issues to our attention. You can see more of his excellent Revolution tips, tricks and tutorials online.