你怎么知道程序的启动方式。 [英] how do you tell how the program was launched.

查看:97
本文介绍了你怎么知道程序的启动方式。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何判断在C ++ MFC中编写的程序是否是从dos,桌面链接启动的。 Program.exeData.xyz或通过单击数据文件Data.xyz启动,其中xyz与Program.exe相关联?



谢谢,

解决方案

我aasume你拥有上述申请的源代码。



你可以做些什么从申请人那里知道的情况;

-通过链接的额外参数(快捷方式)

- 当点击相关数据文件时,文件路径参数将通过。

- 从命令行可以传递任何东西(很难决定)


fronthaus写道:

如果点击数据文件和程序已经在内存中我希望程序加载数据文件而不加载新的exe。

这是一个完全不同的故事,完全不相关应用程序是如何启动的,这实际上是无关紧要的。



你刚才需要检测相同应用程序(进程)的先前实例是否正在运行,将新命令行参数从新实例传递到第一个实例并立即终止;并且第一个实例应该能够接收这些命令行参数并使用它们来添加其他文件。



我需要的技术在我过去的答案中解释:

自定义Windows右键单击命令启动多个实例 [ ^ ],

只向一个流程实例输入多个命令 [ ^ ]。



-SA

How do you tell if a program writing in C++ MFC was launched from dos, desk top link ie. Program.exe "Data.xyz" or launch by clicking on the data file "Data.xyz" where xyz is associated with Program.exe?

Thank you,

解决方案

I aasume you own the source code of the said application.

What you can do in that case to know from wher the application is lunched;
-Pass an extraparamter for the Link(Shortcut)
-When lunched clicking on the associated data file, file path parameter will be passed.
-From command line anything could be passed(hard to decide)


fronthaus wrote:

If the click on the data file and the program was already in memory I want the program to load the data file without loading a new exe.

This is a completely different story, totally unrelated to how the application has been launched, which is actually absolutely irrelevant.

You just need to detect if the previous instance of the same application (process) is running, pass new command line arguments from the new instance to the first one and terminate immediately; and the first instance should be capable of receiving these command line arguments and use them to add additional files.

The techniques you need are explained in my past answers:
Custom Windows right-click command launching multiple instances[^],
Enter multiple commands to only one process instance[^].

—SA


这篇关于你怎么知道程序的启动方式。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆