c# - Pass Parameters to ClickOnce Using ShellExecute -
i attempting use blog pass argument offline click-once application. near bottom of blog there example programs download. downloaded , published program "testrunningwithargs" c# version.
now trying pass argument application not working. keeps saying no "no arguments passed in".
i trying use following code pass argument:
shellexecute("file path\my applicaiton.application","myargument")
this code runs application sample application states did not receive argument. language visual basic (maybe 4 or 6?).
the code below works , allows internet explorer run , specific file opened sharepoint , wondering if there difference missing.
shellexecute("c:\program files\internet explorer\iexplore.exe",filelocation)
the 1 see click once .application file vs .exe , there way work?
below code click once application, copied supplied example program on blog
public partial class mainform : form { public mainform() { initializecomponent(); getargstoshow(); } /// arguments , show them on screen. private void getargstoshow() { // activationarguments setupinformation property of domain. string[] activationdata = appdomain.currentdomain.setupinformation.activationarguments.activationdata; if (activationdata != null && activationdata.length > 0) { //querystring starts ?; file association starts "file:" if (activationdata.length == 1 && activationdata[0].substring(0, 1) == "?") { processquerystring(activationdata); } else if (activationdata.length == 1 && activationdata[0].length >= 5 && activationdata[0].substring(0,5).tolower() == @"file:") { processfileassociation(activationdata); } else { processcsvparameters(activationdata); } } else { if (activationdata == null) { lstargs.items.add("no arguments passed in."); } else { lstargs.items.add(string.format("number of args = {0}", activationdata.length)); } } } /// convert query string name/value pairs , process it. private void processquerystring(string[] activationdata) { namevaluecollection nvc = system.web.httputility.parsequerystring(activationdata[0]); //get keys in collection, pull values each of them. //i'm passing each key once, 1 value. string[] thekeys = nvc.allkeys; foreach (string thekey in thekeys) { string[] thevalue = nvc.getvalues(thekey); lstargs.items.add(string.format("key = {0}, value = {1}", thekey, thevalue[0])); } } /// process if set file association, /// , user double-clicked on 1 of associated file. private void processfileassociation(string[] activationdata) { //this when set file association , user double-clicks // on associated file. uri uri = new uri(activationdata[0]); lstargs.items.add(uri.localpath.tostring()); } /// process comma-delimited string of values. not: can't have spaces or double-quotes in string, /// read first argument. private void processcsvparameters(string[] activationdata) { //i have here i've ever seen 1 entry passed in activationdata, // i'm checking multiples in case. //this takes each entry , splits comma , separates them separate entries. char[] mycomma = { ',' }; foreach (string arg in activationdata) { string[] mylist = activationdata[0].split(mycomma, stringsplitoptions.removeemptyentries); foreach (string oneitem in mylist) lstargs.items.add(oneitem); } } }
edit tried accessing .exe located in "c:\users\username\appdata\local\apps\2.0\5g9cgpwv.6o3\x7ypb07n.2q2\test..tion_0000000000000000_0001.0000_03232931d88a66c9\" did not work.
found file have call send argument.
shellexecute("c:\users\%username%\appdata\roaming\microsoft\windows\start menu\programs\(publisher name)\my application.appref-ms", arguement)
the publisher name specified in visual studio publish tab, options , publisher name. start menu folder program can launched from.
Comments
Post a Comment