c# - Retrive a URI's "return code"? -


i have following problem:

i know how start process , know how use system::diagnostics::process-class, when want start process using associated (and registered) uri protocol, unable retrieve information launched process.

i using following code:

public static int main(string[] argv) {     process p = process.start("myuri://some_arguments");      while (!p.hasexited)         application.doevents();      console.writeline(p.exitcode);     console.readkey(true);      return 0; } 

my c# application fails on 5th line while (!p.hasexited), variable p null.


i wondering: why case? , importantly:

tl;dr: ... how can retrieve uri protocol's "exit/return code"?


edit no.1: the answer @ohw useful - however, cannot use class windows::system::launcher, target machine(s) running on windows7 , not on windows8 or higher

the documentation says process.start return null if no process can started.

i don't think correct way invoke uri's handler. can check out windows.system.launcher.launchuriasync if targeting windows 8/10.

to achieve in earlier versions of windows, can registry find out handler program uri scheme, because handler registered under hkey_classes_root in windows registry. see here implementation in java, , here official documentation.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -