选择一个文件并使用open with打开我的应用程序 [英] Selecting a file and using open with to open with my application

查看:289
本文介绍了选择一个文件并使用open with打开我的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个可以打开(.xyz)格式文件的应用程序.

现在我的问题是,如果我从应用程序打开此文件,它将正确加载该文件.

但是,当我尝试选择文件并右键单击并使用打开方式"并选择我的应用程序时,它不会被加载.仅启动我的application.exe,但未加载文件.

这些是其实现方式的详细信息.
1)我有一个应用程序,可以加载dll并显示其加载的文件格式.
现在,它可以加载(.xyz)和(.abc)两种文件格式.为了加载这些类型的文件,有两个dll.

2)一旦启动exe,它就会在文件夹中搜索dll.如果找到dll,则会提取可以加载文件的文件格式.

3)在启动应用程序并选择文件->从菜单打开,它将在打开的对话框过滤器中显示文件格式,并在浏览并单击打开时加载该格式的文件.


但是当我转到特定文件并单击打开方式"以使用我的应用程序打开时,它不起作用.

Hi,

I have an application that opens a file of format (.xyz).

Now my problem is if i open this file from application , it loads the file correctly.

But when i try to select the file and right click and use "Open with" and select my application, it doesn''t get loaded. Only my application.exe gets launched but file is not loaded.

These are details how its implemented.
1) I have an application, that loads a dll and displays file format which it loads.
Right now two file formats it can load (.xyz ) and (.abc). for loading these types of files, two dlls are there.

2) As soon as exe is launched, it searches for dll in a folder. If it finds the dll, it extracts file format for which files can be loaded.

3) On Launching application and selecting File-> Open from menu, it displays file format in open dialog filter and on browsing and clicking open, it loads the file of that format.


But it doesn''t work when i go to particular file and click Open with to open with my application.

推荐答案

您需要使用Environment.GetCommandLineArgs函数来获取单击的文件名,然后将其打开.像这样的东西:-

You need to use the Environment.GetCommandLineArgs function to get the name of the file clicked and then open it. Something like this:-

string[] appArgs = Environment.GetCommandLineArgs();
string fileName = String.Empty;
if(args.Length >= 2)
{
    fileName = args[1];
}



将其放在您的Main()函数中.

希望这对您有帮助



Put this in your Main() function.

Hope this helps


您似乎认为它应该自动"发生.为什么?您为此做了什么?
除其他外,您可以使用我的库,该库使用起来非常简单并且可以很好地维护应用程序:基于枚举的命令Line Utility [ ^ ].

—SA
It looks like you think that it should happen "automatically". Why? What have you done for this to happen?
Among other thing, you can use my library which is very simple in use and good to maintain the application: Enumeration-based Command Line Utility[^].

—SA


这篇关于选择一个文件并使用open with打开我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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