如果我为程序创建了新的文件类型,则如何使用“打开方式"?适当地? [英] If I make a new file type for my program, how do I use "Open With" properly?

查看:115
本文介绍了如果我为程序创建了新的文件类型,则如何使用“打开方式"?适当地?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个程序.我还创建了自己的文件类型,程序可以创建,打开和编辑该文件类型.在资源管理器中,我右键单击此新文件类型,然后选择打开方式",然后选择我的程序.当然,它只是打开程序而不加载文件.

I made a program. I also made my own file type, which the program can create, open, and edit. In Explorer, I right clicked on this new file type and selected "Open With" and chose my program. Of course, it just opens the program without loading the file.

如何让我的程序知道在启动时被要求打开文件? 打开方式"会发送一些命令行参数吗?

How do I let my program know that it's being requested to open a file on startup? Is there some command line argument that "Open With" sends?

推荐答案

是的,Windows资源管理器将文件的路径作为命令行参数发送到应用程序的可执行文件.

Yes, Windows Explorer sends the path of the file as the command line argument to the executable of your application.

您可以在C#中使用args[0]或在C ++中使用argv[1]来读取它.

You could use args[0] in C# or argv[1] in C++ to read it.

这篇关于如果我为程序创建了新的文件类型,则如何使用“打开方式"?适当地?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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