Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating self-opening documents

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.

like image 550
DanTheMan Avatar asked Oct 10 '22 17:10

DanTheMan


1 Answers

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.

like image 190
jwd Avatar answered Oct 19 '22 23:10

jwd