Saturday, May 11, 2013

Does using the registry disturb the use of settings?

I'm using Visual Basic 2010 Express and have written an application in which the user can open and edit files. The files are associated to the application and are in an XML format. They have a file extension (.vko) that is customized for the application. I have a number of user settings that keep track of window sizes and such. I have them all on the Settings tab in the project properties.

I also want the user to be able to start the application by doubleclicking an associated file that has the extension (.vko). I have managed to find the following method that makes it possible to use the CommandLineArgs.



My.Computer.Registry.ClassesRoot.CreateSubKey(".vko").SetValue _
("", "vko", Microsoft.Win32.RegistryValueKind.String)

My.Computer.Registry.ClassesRoot.CreateSubKey _
("vko\shell\open\command").SetValue("", Application.ExecutablePath & _
" ""%l"" ", Microsoft.Win32.RegistryValueKind.String)

Saving and retrieving the user settings as well as using My.Application.CommandLineArgs to catch the filename work perfectly fine separately. However I have discovered that when using the registry and settings as mentioned above at the same time the application behaves differently when starting it with an argument as opposed to when simply starting it from the Start menu. I get different user settings depending on the start method. This is very annoying.

I have tried running the application both on a computer with Windows XP as well as a different computer with Windows 7. The result is the same.


I'm guessing that using the registry and settings at the same time might be causing the problem but I can't find an alternative solution to using the registry.


What am I doing wrong?





No comments:

Post a Comment