The question says it all. Basically, I just want to know the alternative for this in WinRT:
Process.Start("http://www.google.com/");
In WinRT, you can use Windows.System.Launcher.LaunchUriAsync to launch the default app associated with the specified URI. For a web link, the default browser would be used.
MSDN: Launcher.LaunchUriAsync(Uri) | launchUriAsync(Uri) method
You can use Windows.System.Launcher to launch files and URL's...
Windows.System.Launcher.LaunchUriAsync(Uri) will launch a given Uri with the default application. If it's a link it will open with default web browser. You can use file:/// scheme to open an network resource, but not resources on the local file system.
Windows.System.Launcher.LaunchFileAsync(IStorageFile) will launch the default application for the given file.
Both that methods has an optional second parameter of type Windows.System.LauncherOptions that customizes the launch.
Related
So just like uTorrent gets magnet links and opens them,
How can I setup my WinForm app to get a URL from Default Browser (in this case my default is Chrome) and open that URL in EO.WebBrowser within my app?
I don't have any code for this yet, as I don't know where to start.
Is this something that would be assigned as a Registry Key?
I know there are Registry keys for uTorrent to handle Magnet links in HKEY_CLASSES_ROOT\Magnet\shell\open\command.
What I have is WhatsApp Web open in EO.WebBrowser, and when I click on a URL starting with https://web.whatsapp.com or https://api.whatsapp.com it would open that link. The thing is the link should be changed to web.whatsapp.com, instead of api.whatsapp.com
So i'm opening a standalone Unity app from a UWP store app. In my UWP app I use the unity WSA class to launch the custom uri I created.
Example:
In the register I created a custom uri called test:
In UWP app c# I use:
string uri = #"test:";
// Launch the URI
Launcher.LaunchUri(uri, true);
This works fine. The app launches. However if the app does not exist it pops up a dialogue to ask me with what I want to open it. Can I check this also while launching? So if the user has the app not installed I give the user feedback? I tried pretty much every class available for Unity and uri's etc. None of them do what I need. I had high hopes for a few, but all they did was tell me if the URI i entered are valid uri formats, rather then checking if it can actually open the app.
EDIT: Also, what's the difference between Launcher.launchURI and Application.OpenURL?
Application.OpenURL opens a url in the default browser, while Launcher.LaunchUri starts the default app associated with the specified URI.
And no, from the UWP app you just can’t query the system whether the URI is registered or not, there is no such API.
And LaunchUri just returns false if no app is launched, but at that time an error dialog is already prompted, so checking the return value of LaunchUri is not a solution either.
I created my ClickOnce application witch will install a small windows form application that consists on a WebBrowser control... I need to pass some arguments (this is made per client instalation) in order to open it correctly...
as an example, let's say that I need arg(0) to be the url to open, if I generate a normal Setup I will end up with the .exe file and all I need to do is:
myWebBrowser.exe "http://www.google.com"
but because I'm using ClickOnce method, I'm ending up with
myWebBrowser.appref-ms
if I open it it contains as normal the URL and other parameters
http://www.myWebSite.com/My.WebBrowser/MyWebBrowser.application#My Web Browser.application, Culture=neutral, PublicKeyToken=5f83fa0e3f8a8c2b, processorArchitecture=msil
and I can't pass arguments in it :(
What is the trick for this?
added
I do have "Allow parameters" active
(source: balexandre.com)
resources
I found out about this blog post... I will try it and post my findings
You should be able to use query string like normal...
http://someserver/folder/some.application?a=b&c=d&e=f
The trick is how your app looks for those arguments (plus it must have url arguments enabled in the publish properties) - you should check System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed - if set, look at either AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData (the first item in the array) or (simpler) the ActivationUri of the current deployment.
I know there is built-in Internet explorer, but what I'm looking for is to open Firefox/Mozilla window (run the application) with specified URL. Anyone can tell me how to do that in C# (.nET) ?
You can do this:
System.Diagnostics.Process.Start("firefox.exe", "http://www.google.com");
This will launch the system defined default browser:
string url = "http://stackoverflow.com/";
System.Diagnostics.Process.Start(url);
Remember that Process.Start(url) might throw exceptions if the browser is not configured correctly.
See ProcessInfo.UseShellExecute
Use the Process class (System.Diagnostics) using the URL as the process name. This will use the system default browser to open the URL. If you specify a browser, you run the risk that the browser doesn't exist.
In Visual Studio click the File -> Browse With... on the menus and then select the browser that you want to use. You can also change the browser there. If the Browse With... menu option doesn't appear then you need to select a project from your solution that that can be launched in a browser.
If you explicitly do not want to use the User's default browser, you can run the browser with the URL as the first argument.
C:\Program Files\Mozilla Firefox>firefox.exe http://google.com
launches Firefox with google for me. But as people have said, you run the risk of it not being installed, or being installed to a different place, etc.
I need to launch a media file from a URL from within my c# .NET application. Is there any way to do this natively in .NET? I don't need an embedded player, I just need the default player to launch. I have tried
System.Diagnostics.Process.Start("File URL");
but it launches the default browser and downloads the file, instead of attempting to play it in WMP/VLC/whatever the default media player is. Any ideas?
If you enter an URL it will be handled with the program registered to that URL format, in your case the default web browser.
What format are the media in? You can get associated program for an extension and then run that program with the url as parameter.
See:
Windows: List and Launch applications associated with an extension
So if your media is for example .MP3, then find the assoicated program for .MP3 (using the code in the link above) and pass the url as a parameter to that program.
Another way to handle this is to temporary download the file to the local file system and then run your
System.Diagnostics.Process.Start("Local File");
Then it should work as you expect.