如果我为我的程序创建一个新的文件类型,如何正确使用“打开方式”?

时间:2022-02-16 07:07:34

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?

如何让我的程序知道它被要求在启动时打开文件?是否有一些命令行参数“打开方式”发送?

1 个解决方案

#1


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

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

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

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

#1


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

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

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

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