|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Error 5: ERROR_ACCESS_DENIED when accessing registry in Windows 7Having the full administrative privileges I have ERROR_ACCESS_DENIED response from RegSetValueEx{} Code: rtn = RegCreateKey(HKEY_CLASSES_ROOT, "callto\DefaultIcon", phkResult) If rtn = ERROR_SUCCESS Then >cut< rtn = RegSetValueEx(phkResult, "Orig", 0&, REG_SZ, ByVal lpName, Len(lpName)) End If In above code RegSetValueEx{} returns Error 5 How to fix that problem? The above code works fine in Win XP, only Windows 7 is causing that problem. Thanks, Claire Claire wrote on 9/1/2010 :
> Hello, Are you sure? On windows vista and 7, if UAC is on, just because you > Having the full administrative privileges I have are running an admin account, doesn't mean you actually have full admin privileges. You need to include a manifest... I haven't done this in VB6, so hopefully you'll get some better information - but, I am under the impression you will want to add it as an embedded resource to your exe. -- Tom Shelton On 02/09/2010 04:16, Tom Shelton wrote:
> Claire wrote on 9/1/2010 : You can find more info on this at:>> Hello, >> Having the full administrative privileges I have > > Are you sure? On windows vista and 7, if UAC is on, just because you are > running an admin account, doesn't mean you actually have full admin > privileges. > > You need to include a manifest... I haven't done this in VB6, so > hopefully you'll get some better information - but, I am under the > impression you will want to add it as an embedded resource to your exe. http://hashvb.earlsoft.co.uk/Vista_UAC_and_Elevation It also explains the COM elevation method for a nicer method to properly ask for elevation while already running. -- Dee Earley (dee.ear***@icode.co.uk) i-Catcher Development Team iCode Systems (Replies direct to my email address will be ignored. Please reply to the group.) "Claire" <replyto@fra> wrote in message Not sure what access is given to keys open by RegCreateKey(). Try news:eTJSImkSLHA.3580@TK2MSFTNGP06.phx.gbl... > rtn = RegCreateKey(HKEY_CLASSES_ROOT, "callto\DefaultIcon", RegCreateKeyEx() instead. I am assuming here that you have UAC turned off, or you used "Run As Administrator". Thank you both.
It was UAC turned on. That invites the new question. My code adds to Windows URL protocol callto:// when protocol does not exists or it modifies it, so the programs like Firefox can understand what to do with that. The same operation is also done by Skype but I did not notice ever that Skype asks the user to turn UAC off. How that can be possible? Yours comments appreciated, Claire Show quoteHide quote "Claire" <replyto@fra> wrote in message news:eTJSImkSLHA.3580@TK2MSFTNGP06.phx.gbl... > Hello, > Having the full administrative privileges I have > ERROR_ACCESS_DENIED response from > RegSetValueEx{} > Code: > rtn = RegCreateKey(HKEY_CLASSES_ROOT, "callto\DefaultIcon", > phkResult) > If rtn = ERROR_SUCCESS Then > >cut< > rtn = RegSetValueEx(phkResult, "Orig", 0&, REG_SZ, ByVal > lpName, Len(lpName)) > End If > > In above code RegSetValueEx{} returns Error 5 > > How to fix that problem? > The above code works fine in Win XP, only Windows 7 is causing that > problem. > Thanks, > Claire > Claire submitted this idea :
> Thank you both. That's the point of the manifest I was talking about...> It was UAC turned on. > That invites the new question. > My code adds to Windows URL protocol callto:// when protocol does not exists > or it modifies it, so the programs like Firefox can understand what to do > with that. > The same operation is also done by Skype but I did not notice ever that Skype > asks the user to turn UAC off. > How that can be possible? -- Tom Shelton I wish I understand what you talk about the manifest.
BTW, I am using vbasic 5. Claire Show quoteHide quote "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message news:i5nc64$4fc$1@news.eternal-september.org... > Claire submitted this idea : >> Thank you both. >> It was UAC turned on. >> That invites the new question. >> My code adds to Windows URL protocol callto:// when protocol does not >> exists or it modifies it, so the programs like Firefox can understand >> what to do with that. >> The same operation is also done by Skype but I did not notice ever that >> Skype asks the user to turn UAC off. >> How that can be possible? > > That's the point of the manifest I was talking about... > > -- > Tom Shelton > > On 02/09/2010 06:02, Claire wrote:
> Thank you both. It was most likely done during the setup where it would have asked for > It was UAC turned on. > That invites the new question. > My code adds to Windows URL protocol callto:// when protocol does not exists > or it modifies it, so the programs like Firefox can understand what to do > with that. > The same operation is also done by Skype but I did not notice ever that > Skype asks the user to turn UAC off. > How that can be possible? permission to "have access to your computer". -- Dee Earley (dee.ear***@icode.co.uk) i-Catcher Development Team iCode Systems (Replies direct to my email address will be ignored. Please reply to the group.) no, it cannot be.
When app is running, doing that it makes Windows aware where to hook up the callto:// protocol. When application terminates it should restore callto"// to the previous state. So, it must be done each time app starts and terminates, not during the setup only. Claire Show quoteHide quote "Dee Earley" <dee.ear***@icode.co.uk> wrote in message news:OPTD5soSLHA.3580@TK2MSFTNGP06.phx.gbl... > On 02/09/2010 06:02, Claire wrote: >> Thank you both. >> It was UAC turned on. >> That invites the new question. >> My code adds to Windows URL protocol callto:// when protocol does not >> exists >> or it modifies it, so the programs like Firefox can understand what to do >> with that. >> The same operation is also done by Skype but I did not notice ever that >> Skype asks the user to turn UAC off. >> How that can be possible? > > It was most likely done during the setup where it would have asked for > permission to "have access to your computer". > > -- > Dee Earley (dee.ear***@icode.co.uk) > i-Catcher Development Team > > iCode Systems > > (Replies direct to my email address will be ignored. > Please reply to the group.) "Claire" <replyto@fra> wrote in message There are somethings that can apply on a per user bases. Perhaps you can use news:u$EDjwlSLHA.2100@TK2MSFTNGP04.phx.gbl... > Thank you both. > It was UAC turned on. > That invites the new question. > My code adds to Windows URL protocol callto:// when protocol does not > exists or it modifies it, so the programs like Firefox can understand what > to do with that. > The same operation is also done by Skype but I did not notice ever that > Skype asks the user to turn UAC off. > How that can be possible? HKEY_CURRENT_USER instead. I know that COM can be registered per user, but I am not sure about protocols. Private Declare Function IsUserAnAdmin Lib "shell32" () As Long
You may use this API to check if the application have admin rights. You need to run the application with Admin rights to right to system areas like HKEY_LOCAL_MACHINE and things like making files association. I would recommend removing parts from your app which requires admin privileges and making them a separate mini exe, and opening them when needed with admin rights invoking the UAC elevate privileges prompt. This way your main program will continue to run with "low" rights but still be able to making system wide changes by showing the user UAV prompt. OR shell execute your main program with admin rights and making necessary changes like task manage do when click 'show processes from all users' here is the code for invoking UAC dialog. Private Declare Function apiShellExecuteA Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Public Function ShellExUAC(ByVal strUrl As String, ByVal hwnd As Long, Optional ByVal strCmdArgue As String = vbNullString, Optional ByVal strDirectory As String = "", Optional ByVal lngShowCmd As VbAppWinStyle = vbNormalFocus) As Long '------------------------------------------------------------------------- ' Procedure : ShellExUAC ' DateTime : 30-Nov-08 00:08 ' Author : abhishek binaryli***@yahoo.com ' Purpose : To invoke Windows Vista or Above UAC Dailog ' Notes : Should only be used on ' 1. Windows Vista or Above ' 2. When User is not An Admin ' Minimum OS: Windows Vista or Above. '------------------------------------------------------------------------- ShellExUAC = apiShellExecuteA(hwnd, "runas", strUrl, strCmdArgue, strDirectory, lngShowCmd) End Function -- Show quoteHide quoteVB6 Zone - Blog on Supporting VB6 http://vb6zone.blogspot.com VB6 Petition to Microsoft http://www.classicvb.org/petition/ Free newsgroup servers: www.aioe.org www.eternal-september.org Classic VB Users Regrouping at: microsoft.public.vb.general.discussion comp.lang.basic.visual.misc "Claire" <replyto@fra> wrote in message news:eTJSImkSLHA.3580@TK2MSFTNGP06.phx.gbl... | Hello, | Having the full administrative privileges I have
Error 481 Invalid picture
Global class and WithEvents Distibution of VB6 program Lockup Continues Why doesn't this work (sendmessage) Radio Button Bug? file and folder permissions Showing/Using Sort arrows on vb6 listviews? Closing Grouped instances in the taskbar Componenet not installed correctly by PDW |
|||||||||||||||||||||||