launch a Windows application from a web browser - windows

I'm trying to launch a Windows application from a web browser, just like the VMWare console (VMRC) from a vCenter web interface, or the Zoom binary from a simple html link.
I understand Java applets, NAPI protocol and ActiveX are considered deprecated, so what is the best method please?
Thanks.

Register as a protocol handler in the registry.
To handle foo://something URLs for example, the .reg file would look something like
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\foo]
"URL Protocol"=""
[HKEY_CLASSES_ROOT\foo\shell\open\command]
#="\"C:\\Program Files\\MyApp\\MyApp.exe\" \"%1\""
If your app is not already installed on the system you might want to look at ClickOnce instead.

Related

What API/protocol is used to implement `Share` feature in windows explorer

I want to know the API or protocol of the Share feature in the windows explorer like this
Does anybody have any ideas?
ShowShareUIForWindow (MSDN says it requires Windows 8 but it actually only works in Windows 10/11 in a normal desktop application).
How do I show the sharing pane from a Win32 desktop application?

How to add my protocol into default programs in windows 10?

Hi I have a new protocol URL:myTest, how can I add it in windows 10 so I can see it listed in default programs? Shall I add it in registry? How/Where exactly could I do that?
I want to associate a program with this protocol.
The registration for "Default Programs" is in the registry under SOFTWARE\RegisteredApplications. If your application fits one of the client types then you should point your RegisteredApplications value to Software\Clients\%ClientType%\%YourCanonicalName%\Capabilities, otherwise you can use any key like Software\%YourCompany%\%YourApp%\Capabilities or Software\Classes\Applications\%Filename%\Capabilities.
The most important subkey in your case is UrlAssociations.
You must also register your protocol in the normal way.
Some of this changed in Windows 10 and I would recommend that you test on Windows 7 or 8 as well. "Default Programs" has been deprecated in Windows 10.
You should also register yourself in the Applications key for integration with the "Open with" dialog.
This is the way it works for pure desktop apps, I'm not sure what happens if you convert a desktop app to UWP. Modern apps declare their protocol in the manifest.

How To Make A Windows Application (.EXE), Which Will Run HTML Webpage

I want to create a desktop application for Windows, which will run specified website url in that. for example look this montage- i want a software like fluidapp.com (Mac Support).
montage link- http://dl.dropbox.com/u/65090365/2013/preview.jpg
There is a windows forms WebBrowser control which should do what you want.
http://msdn.microsoft.com/en-us/library/2te2y1x6.aspx

How can Windows Sidebar Gadget communicate with my desktop app?

I've got a .NET 2.0 Windows desktop application (time-sheets) which i develop and wanted to add a Gadget interface to it (so that app runs hidden and is controlled via the gadget).
What is the easiest way to get my gadget to communicate to my app?
An idea that i had was to have a built-in web server inside the app, and the gadget controls communicates with the app using ajax. However i'm hoping there's a simpler solution.
You didn't specify what technology the gadget and app were written with, so it's hard to answer. Assuming you can use .NET, WCF with a named-pipes binding would be very simple. Just a few lines of code to set it up.
We use win32 APIs in one of our gadgets' ActiveX control to communicate with other instances of the same gadget. Unfortunately, I can't give you the code (because I don't have permission and I don't write the .net stuff) but it boils down to using a window (in your case the application window) as a server and the gadget ActiveX control as the client and use the SendMessage function.
You can see an example of using COM interop with windows desktop gadgets at http://www.codeproject.com/KB/gadgets/GadgetInterop.aspx
NB: make sure the interop assembly is in the application's directory and NOT the gadget directory, otherwise you'll run into problems when updating/uninstalling the gadget.

Getting Default browser

How can I determine which is the default browser in my system programatically. The code must be developed using vc++
Is there any API for this ?
Where in the registry is the default browser value stored?
TL;DR: If HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\ exists read that; otherwise read HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\.
After reading the answers here I found little concensus on how to detect the default browser so I did some experiments and research to figure it out. I downloaded the Firefox source, wrote a script that reads a bunch of registry entries and also ran Process Explorer all while changing the default browser over and over.
I found there are a lot of registry keys that Firefox and Chrome change when each sets itself as the default browser. I believe Safari and Opera are both similar in behavior. IE appears to change only one of the registry keys I was watching.
What I found was that while most browsers change other registry paths, all browsers change HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\ (default)
Here are the registry value from the registry key HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\ (default) while each browser is the default browser.
IE 9.0.8112.16421: IEXPLORE.EXE
Chrome 21.0.1180.60 m: Google Chrome
Firefox 10.0.2: FIREFOX.EXE
Safari 3.2.2: Safari.exe
Opera 12.01: Opera
Tested on Microsoft Windows 7 Home Premium SP1 64-bit
Edit:
I found on a fresh install of Windows XP SP3 HKEY_CURRENT_USER\SOFTWARE\Clients\StartMenuInternet\ does not exist. In this case you should read the default browser from HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\. I suspect this is also the case on fresh installs of other versions of Windows.
Addendum:
The ShellExecute method is a great solution if all you want to do is open a web page in the default browser. However, if you want to, for example, install an extension in only the default browser, ShellExecute does not solve the problem.
You normally do not need to know this. ShellExecute(0,0,"http://stackoverflow.com",0,0,SW_SHOWNORMAL); will do the trick. Windows will spot the http:// and figure out from there that you want to open a URL. The "default" webbrowser is pretty much defined as the webbrowser used by Windows for this task.
It's not just http:// which is supported. ShellExecute can start the default webbrowser with https:// URLs as well. For mailto: URLs, it starts the default mail client.
you can find the default browser in the registry
i.e. for Windows XP and Vista is located at
HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\
As its name suggests, StartMenuInternet is for registering a Web browser onto the Start Menu (and it only applies to XP and Vista, it is deprecated starting with Windows 7). That does not necessarily establish the browser as the default browser for the entire system. There are many different ways a browser can be registered for different purposes (loading a file, loading a URL, loading data based on a MIME type, etc). Each of those registrations are separate.
Default Programs
How to Register an Internet Browser or Email Client With the Windows Start Menu
Registering an Application to a URL Protocol
File Types
Personally, I would probably look at the registration of the "http" and/or "https" URL handler to determine the default browser, since that will be the app that loads when the user types a URL into the Start Menu or Windows Explorer, or an app passes a URL to ShellExecute/Ex().
Read the default value of HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet and optionally check HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\XXX\shell\open\command where XXX is that value picked up from the first key.

Resources