创建自打开文档

发布于 2024-11-15 23:38:10 字数 451 浏览 8 评论 0原文

我正在开发一个具有专有文件格式的项目。该项目有一个需要安装的大型程序和一个不需要安装的较小查看器。我希望能够从我的主应用程序导出“自打开”.exe 的文件 - 也就是说,您可以双击 exe,嵌入的文件将显示(这是为了将查看器传递给拥有以下权限的人)未安装能够查看它的主应用程序 - 他们只会传递文档)。

我有点不知道如何做到这一点。我一直在调查的两个想法已经走进了死胡同。它们是:

1) 将文件嵌入查看器中。我可以通过 Visual Studio 手动执行此操作,并且我有一个工作演示,但我无法找到一种即时执行此操作的方法。

2) 创建一个自解压存档,将文件和 exe 解压到临时目录,并在命令行上使用文件名运行 exe。这听起来很简单而且可能(尽管很老套),但我遇到了一个问题,即归档或安装程序似乎没有执行所有这些操作所需的命令行。

有什么想法吗?我更喜欢第二个,因为它很简单,但第一个是因为它看起来更防弹/更少黑客。

I'm working on a project that has a proprietary file format. The project has a large install-necessary program and a smaller viewer that requires no install. I would like to be able to export files from my main application that are 'self opening' .exe's - that is, you can double click the exe and the embedded file will show (this is to make passing around the viewer to people who have NOT installed the main application able to view it - they will only pass around the document).

I'm a little lost on how to do this. My two thoughts that I've been investigating have come to a dead end. They are:

1) Embed the file in the viewer. I can do this manually through Visual Studio, and I've got a working demo of that, but I can't figure out a way to do this on the fly.

2) Create a self-extracting archive that extracts the file and the exe to temp and runs the exe with the file's name on command line. This sounds easy and possible (albeit hacky), but I've run into the issue that archive or install programs don't seem to have the command line necessary to do all that.

Any ideas? I prefer the second because it's easy, but the first because it seems more bullet proof / less hacky.

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

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

发布评论

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

评论(2

清秋悲枫 2024-11-22 23:38:10

使用方法 (1):

如果您使用 .NET,则可以将查看器程序设置为一个程序集,将文档设置为另一程序集,然后使用 ILMerge 等将它们组合成一个最终的可执行文件。

ILMerge 是一个命令行程序,因此您应该能够自动执行该步骤。

这样,您的自定义查看器就应该相当容易,本质上只是“加载与我一起的其他程序集”,并且可能调用其他程序集上的函数来获取数据。

唯一的另一个难题是如何生成“文档”程序集。我不完全确定这些步骤,但看起来应该是可行的。

也许使用 CMake 或类似工具生成 VStudio 项目,然后使用 MSBuild 将其构建为程序集。

Using your method (1):

If you are using .NET, you could make your viewer program be one assembly, and your document be another assembly, then use ILMerge or the like to combine them into one final executable.

ILMerge is a commandline program, so you should be able to automate that step.

That way it should be fairly easy to have your customized viewer essentially just "load the other assembly that's with me" and perhaps call a function on the other assembly to get the data.

The only other piece of the puzzle is how to generate the 'document' assembly. I'm not entirely sure of the steps, but it seems like it should be doable.

Perhaps use CMake or similar to generate a VStudio project, and then use MSBuild to build it into an assembly.

情徒 2024-11-22 23:38:10

虽然将 exe 捆绑到文档中以使其成为自打开文档是一个很酷的想法,但我认为这并不是解决问题的最佳方法。问题在于这些文档需要特定的查看器,而该查看器并不容易获得。因此,要让观众尽可能容易地接触到。

这就是 Xint0 在评论中建议的。找到一种方法让观众尽可能容易地接触到。无需担心盗版,因为它只是专有格式的查看器,因此唯一对其感兴趣的人将是已经拥有无法打开的文档的人。因此,将查看器发布在您公司的网站上,并鼓励使用完整软件的公司在其网站上发布查看器的链接,以便客户可以轻松找到它。

While bundling the exe into the document to make it a self-opening document is a cool idea, I don't think it's the best solution to the problem. The problem is that the documents require a specific viewer that is not readily available. So make the viewer as easy to get as possible.

And that's what Xint0 suggested in the comments. Find a way to make the viewer as readily available as possible. No need to worry about piracy as it's only a viewer for a proprietary format so the only people interested in it will be people who will already have a document they can't open. So post the viewer on your company website and encourage the companies using the full software to post links to the viewer on their websites so that their customers can easily find it.

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