| OLD | NEW |
| (Empty) |
| 1 // Copyright 2008-2009 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 // ======================================================================== | |
| 15 | |
| 16 // C# stub that allows a ClickOnce install of an Omaha application. | |
| 17 | |
| 18 using System; | |
| 19 using System.Deployment.Application; | |
| 20 using System.Diagnostics; | |
| 21 using System.IO; | |
| 22 using System.Security; | |
| 23 using System.Security.Permissions; | |
| 24 using System.Windows.Forms; | |
| 25 using System.Web; | |
| 26 | |
| 27 namespace ClickOnceBootstrap { | |
| 28 static class ClickOnceEntry { | |
| 29 [STAThread] | |
| 30 static void Main() { | |
| 31 try { | |
| 32 // Try to get FullTrust. Will throw if we cannot get it. | |
| 33 new PermissionSet(PermissionState.Unrestricted).Demand(); | |
| 34 | |
| 35 if (!ApplicationDeployment.IsNetworkDeployed) { | |
| 36 // Only support running via ClickOnce. | |
| 37 return; | |
| 38 } | |
| 39 | |
| 40 string query_string = | |
| 41 ApplicationDeployment.CurrentDeployment.ActivationUri.Query; | |
| 42 if (query_string.Length < 2) { | |
| 43 // Query string will be of the form "?xyz=abc". Should have atleast | |
| 44 // a question mark and atleast a single character to qualify as a | |
| 45 // valid query string. Hence the check against "2". | |
| 46 return; | |
| 47 } | |
| 48 // Remove the '?' prefix. | |
| 49 query_string = query_string.Substring(1); | |
| 50 query_string = HttpUtility.UrlDecode(query_string); | |
| 51 string setup_path = Path.Combine(Application.StartupPath, | |
| 52 "GoogleUpdateSetup.exe"); | |
| 53 | |
| 54 ProcessStartInfo psi = new ProcessStartInfo(); | |
| 55 psi.FileName = setup_path; | |
| 56 psi.Verb = "open"; | |
| 57 psi.Arguments = "/installsource clickonce /install \""; | |
| 58 psi.Arguments += query_string; | |
| 59 psi.Arguments += "\""; | |
| 60 Process.Start(psi); | |
| 61 } catch(Exception e) { | |
| 62 MessageBox.Show(e.ToString()); | |
| 63 return; | |
| 64 } | |
| 65 | |
| 66 return; | |
| 67 } | |
| 68 } | |
| 69 } | |
| 70 | |
| OLD | NEW |