使用我的应用程序打开窗口

发布于 2024-08-30 12:56:56 字数 160 浏览 1 评论 0原文

我编写了一个应用程序,它将能够打开特定扩展名的文件并将其显示给用户。现在我希望用户只需双击该文件即可使用我的应用程序将其打开。我尝试在Windows“打开方式”对话框中设置“始终使用所选程序...”选项,但不知道如何接收Windows发送到我的应用程序的文件名。如何做到这一点?

谢谢...

I wrote an application which will be able to open files of particular extension and show it to users. Now I want the users to be able to just double click the file and have it open with my application. I tried to set the "Always use the selected program..." option in the windows "Open With" dialog box, but do not know how to receive the file name that Windows sends to my application. How to do this?

Thanks...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

长途伴 2024-09-06 12:56:56

文件名将作为参数传递给您的应用程序。
例如,在 c# 中,您将得到这样的结果:

static class Program

[STAThread]
static void Main(string[] args)
{
  if (args.Length > 0)
  {
    string filename = args[0];
  }
}

The file name will be passed to your application as an argument.
For example, in c#, you will get it like this:

static class Program

[STAThread]
static void Main(string[] args)
{
  if (args.Length > 0)
  {
    string filename = args[0];
  }
}
苍景流年 2024-09-06 12:56:56

如果我理解得很好,你需要这样的东西:

~ Notepad test.txt 

所以,你需要在你的应用程序中做出一个可选的参数。如果存在,则打开该文件。如果没有,请打开一个新文件。

If I understood well, you need something like:

~ Notepad test.txt 

So, you need to make an optional argument in your application. If it exists open the file. If not, open a new file.

记忆消瘦 2024-09-06 12:56:56

您应该在应用程序的启动参数中收到文件名

You should receive the filename in your application's startup parameters

把昨日还给我 2024-09-06 12:56:56

Windows 将文件名作为启动参数传递给您的应用程序。您需要在 WinMain 或应用程序入口点中处理此问题。

Windows passes the filename as a startup parameter to your application. You will need to handle this in your WinMain or application entry point.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文