Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Dec 09, 2019 3:10 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: HKEY_CLASSES_ROOT ... RegistryAccessErrorException
PostPosted: Wed Jul 13, 2011 10:28 pm 
Offline

Joined: Wed Jun 10, 2009 9:51 am
Posts: 8
Hello, I searched the forums but couldn't find if there is another way to do urlhandlers on windows. I am using the below code to register my app's urlhandler in the registry so when a user clicks on a link like: myap://sendmsg
it will open my program and do a certain action.

It works fine on eight of the systems I have tried it on, but I have noticed that systems
with tighter security (e.g. one of my windows 7 clients) it fails to work, and the program returns a RegistryAccessErrorException. I was wondering if there is another location that I can use and get the same effect (I assume HKEY_CLASSES_ROOT is locked on some systems) or even an alternative method--or work around--that will still allow me to get the urlhandler to work on all versions of windows.


registerhandler(url as string, explanation as string)
#if targetwin32
dim y as integer
dim r, r2 as registryItem
r = new registryitem("HKEY_CLASSES_ROOT")
r = r.addFolder(url)
r.defaultValue = "URL:"+explaination
r.value("URL Protocol") = ""
r2 = r.addFolder("DefaultIcon")
r2.defaultValue = app.ExecutableFile.shellPath
r2 = r.addFolder("Shell")
r2 = r2.addFolder("Open")
r2 = r2.addFolder("Command")
r2.defaultValue = chr(34)+app.ExecutableFile.shellPath+chr(34)+" %1"
#endif


Thanks


Top
 Profile  
Reply with quote  
 Post subject: Re: HKEY_CLASSES_ROOT ... RegistryAccessErrorException
PostPosted: Wed Jul 13, 2011 11:15 pm 
Offline

Joined: Mon Sep 22, 2008 9:01 pm
Posts: 61
Probably cuz you or whoevers executing the code doesn't have permission in that section of the registry.
You'll want to use HKEY_CURRENT_USER instead as it doesn't require admin privs.

Here is the code i've been using for my program for the past several years, it appears to work rather well.
Quote:
dim reg as registryItem
reg = new registryItem("HKEY_CURRENT_USER\Software\Classes\palace")


reg.DefaultValue="URL:Palace Protocol"
reg.Value("URL Protocol")=""
reg = new registryItem("HKEY_CURRENT_USER\Software\Classes\palace\shell\open\command")

reg.Value("") =app.ExecutableFile.absolutePath+" %1"


Top
 Profile  
Reply with quote  
 Post subject: Re: HKEY_CLASSES_ROOT ... RegistryAccessErrorException
PostPosted: Thu Jul 14, 2011 3:14 am 
Offline

Joined: Mon Sep 22, 2008 9:01 pm
Posts: 61
Or i suppose even better yet you could default to HKEY_CLASSES_ROOT and then use a try catch statement to switch to HKEY_CURRENT_USER instead if there is a access error.

I suppose there is other ways as well to ensure it gets put in HKEY_CLASSES_ROOT, like perhaps with installation software which prompt the user to raise the app to admin level on install, most installer software have some type of registry support i think. But since the registry can be tampered with by other softwares i suppose its a good idea to have your app check the registry on launch to make sure its configured in the way it should be.


Top
 Profile  
Reply with quote  
 Post subject: Re: HKEY_CLASSES_ROOT ... RegistryAccessErrorException
PostPosted: Sat Jul 30, 2011 4:08 am 
Offline

Joined: Wed Jun 10, 2009 9:51 am
Posts: 8
Thank you very much, that works perfectly! (Sorry for the late reply, I've been so busy/underpaid lately ;p )


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group