Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
335 views
in Technique[技术] by (71.8m points)

c# - How do you implement Launching a win32 exe with command line arguments from an UWP app?

I am trying to launch a legacy win32 software that takes command line arguments from my UWP app.

The win32 app (xxx) does not inherently support activation protocols and URI but I was able to add this by using registry entries at:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOTxxx]
@="URL:xxx"
"URL Protocol"=""

[HKEY_CLASSES_ROOTxxxshell]

[HKEY_CLASSES_ROOTxxxshellopen]
@=""

[HKEY_CLASSES_ROOTxxxshellopencommand]
@=""C:\Program Files (x86)\xxx\xxx.exe" "%1""

I have implemented the following in my UWP app but it only launches the app and does not pass the arguments:

 await Launcher.LaunchUriAsync(new Uri("xxx:aaa=123"));

How do I go about passing command line arguments to a Win32 app from UWP?

I don't mind creating a Win32 app or a console app to be the middle man here to read the activation protocol and convert it to a command line argument and run the win32 but could not find any solutions to doing so.

Thanks.

question from:https://stackoverflow.com/questions/65912523/how-do-you-implement-launching-a-win32-exe-with-command-line-arguments-from-an-u

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I tried xxx:aaa=123. However, it passes the argument (%1) as a whole including the protocol. How do I remove or replace the xxx: from %1

And please check @=""C:\Program Files (x86)\xxx\xxx.exe" "%1"", it contain %1 as default. You could remove it manually.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...