Open default browser as standard user (C ++)

I am currently using ShellExecute "open" to open a URL in a user browser, but I have run into minor problems in Win7 and Vista because the program starts as a service.

When ShellExecute opens a browser, it seems to read the "Local Admin" profile, not the user one. For example, if the user on the keyboard has Firefox as the default browser, he can open IE (which is the default administrator).

I know that the verb "runas" can be used to lift, but how do you do it differently? Is there a way to open the URL in the default browser on the standard desktop of the user from the service?

+3
source share
3 answers

ShellExecute will execute the program in the context of the same session and the same user as the process you are running.

If you want to use a different session or user token, you can use the CreateProcessAsUser Win32 API.

There are several ways to get a user token, for example, you can call the Win32 API:

+4
source

:

: , ... , -, "http". - - , "" (. ). HKCR\http, HKCU\Software\Classes\http, HKLM\Software\Classes\http .

  • "HKEY_CURRENT_USER\Software\Clients\StartMenuInternet"
  • "HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\\shell\open\command"
  • ".exe"

, .

(, w2k), http.

, , , . ( ShellExecute >= Vista). (), ( IE , DDE).

.

+2

Aaron Margozis has an example with a 7-step native code at http://blogs.msdn.com/aaron_margosis/archive/2009/06/06/faq-how-do-i-start-a-program-as-the-desktop -user-from-an-elevated-app.aspx . It will not help you in maintenance if this is what you have. I agree that your service should not try to run the application as a registered user, especially since it may not be there.

0
source

Source: https://habr.com/ru/post/1733824/


All Articles