How To Export exe files in Visual Studio With All Used Files - visual-studio-2010

So I have been working on a few projects using audio and images from files in Visual Studio C++. As of now they are just test projects, but I am going to be moving now towards making 2D games for fun using SFML and a few different audio libraries. The problem is this, I want to give out my games to others so they can play and test them, and I may try to develop some sort of Multiplayer for some, thus increasing my desire to give it out to others, however I do not know how I can give them the games with all the files included. I used to just be able to grab the exe files out of the debug or release folder, but these projects have files they rely on.
So here is my question, is it possible to export an exe file that contains all the other files (wav's, jpg's etc.)? If this question sounds overwhelmingly stupid then tell me, because I have very little idea of what an exe is, and whether it can hold those files (I am used to java, where u can simply export something into a runnable jar and because it is an archive, with all of the resources prepackaged in there, I don't know if an exe shares these traits). If this is not possible, or there are better alternatives, what are they? I have seen things and know how to load sounds from arrays of data, would that be a better solution? Or are there other options? On top of that, in the debug and release folder there are several DLL files which I need to run the project, is there a way to compress these into the exe or will those have to be in the same folder as the exe no matter what?
The real question here is what is the best way to export an exe file of my project so that I can utilize all of my sound and image resources as well as the dll's into an easy to distribute copy? Thank you in advance to any advice.

It's not possible to export an exe that contains your exe and multiple other files. You can use an installer (such as InnoSetup, which is free), or bundle the extra files into a resource and load them from resource at runtime. (The first has the benefit of being able to ask the user where to install, create shortcuts and folders, Start Menu items, etc.).

There's two easy ways to make a file that you can easily give to people to test and/or play your game.
The first option is using an installer, as mentioned in Ken White's answer. It's a good method for "final" releases, but it adds an extra step if you just want to send a copy of your game to someone to test it.
The second method is put all your files into a single .zip file (or .rar, or .tar.bz). Basically, this is a lot like Java's .jar file, with all the dlls, image files, and sound files into a single file. Recent versions of Windows have the ability to create zip files built in, so the best way to do it is just zip up the Debug or Release version with all the files, and unzip to an empty folder somewhere, and test the game. Doing that will let you make sure you got all the files you need. This way, you can easily send your game to someone, they can simply unzip it to a folder somewhere, and play, no messing about with installers.
The bonus third option is sticking the files into a resource and loading them at runtime, or similar things (it's possible to get really fancy and combine all the files into a single EXE, but it's not exactly easy, and not really advisable).

Related

Few general questions about JavaFX capabilities

I'm using JavaFX to build a GUI for the software I'm working on. I call it software but it's actually a series of automated steps, compiled into a standalone .exe file. I have about 6 of these executable files, which is why I'm building a GUI to act as the front-end, main menu of sorts.
Ideally I'd have the entire package (GUI, exes) combined into one file Jar which I'd then send to clients, or wrap it with JSmooth or Launch4j.
Questions:
1) Is it possible to combine all 6 .exe files into a package along with the GUI.? So if I click button 2 on the GUI, it runs .exe #2, etc. Which concepts should I understand?
2) Is this best practice, or is there a better method? I'm new to Java which is why I haven't built the entire software with it, just the GUI.
3) I've read that its best to extract the exe from the parent jar (or exe?) into a temp file on the users PC. Is this correct? Even for multiple wrapped exes?
Any answer is helpful. I'm trying to avoid building something only to realize I can't do what I needed. Thanks
It would be much easier to write an answer if you were a bit more specific regarding what those 6 .exe files do. Nevertheless, a few things can be pointed out. Answers are in the same order as questions.
Yes, you can package exe files into a jar. No, you can't run exe from within the jar. A common solution is to unpack exe either temporarily (while your application is active) or permanently, and then tell OS to execute it.
I'm not entirely sure what "best practice" refers to in your question. Ideally, your logic (back-end) code would be written in Java and all your 6 exe files would be a part of a single Java application. I respect that you are new to Java, so in your particular case having a front-end to your executables is perfectly fine. However, do keep in mind that your solution is Windows specific, unless you plan to provide other OS executables too.
Yes, you will need to extract the exe files. It doesn't really matter what parent executable you use (exe or jar). For the sake of simplicity, I'd go with the jar, because you won't need to use any 3rd party software to build such a jar.
Just to sum up, considering your situation, package your JavaFX app and the .exe files into a single executable jar. When the user needs to execute an ".exe", extract that ".exe" into the same directory where JavaFX is running from. When the app exits, delete all ".exe" files from that directory

Making folder containing executable into executable

I have a folder which contains an executable file (Exec.exe) and a lot of files that Exec.exe needs to run. Currently, it's pretty ugly having all of those files there when I only need to run the one executable. Is there any way to bundle them all into another executable that runs Exec.exe and also contains all of the files Exec.exe needs to run? Thanks for any help!
Yes, but I would recommend you only do it if you need to.
You can achieve this by adding your files as resources in your exe project, so they are added into the exe's binary at compile time. You can then access the files directly from your exe at runtime by using LoadResource and related functions. I'd recommend reading up on the Portable Executable (PE) file format if you're considering this route.
This is the way to do it if you, and again I stress, need to have only a single binary where you can still access your files. There are obvious downsides to doing this, such as it's much more coding to access the data as it's embedded in your application binary, and you can't easily update the files (check out resource hacker tool) without re-compiling your binary to include the new data.
If the only reason you want to do this is because it's "pretty ugly" seeing the additional files in the same directory as your exe, consider moving them into another directory, for example,
from:
MyExeDir
--myExe.exe
--myFile1.txt
--myFile2.dll
--myFile3.dat
to:
MyExeDir
--myExe.exe
--dat
----myFile1.txt
----myFile2.png
----myFile3.dat
or:
MyExeDir
--bin
----myExe.exe
--dat
----myFile1.txt
----myFile2.png
----myFile3.dat
So all the "ugly" looking files are out of the way.
Why don't you create a shortcut of "Exec.exe" and keep it somewhere handy ? If whats that you want ?
Or if you want to distribute your app, you can use Winrar/Winzip (winrar is the best) to create a compressed .exe of your entire folder, making "Exec.exe" as your startup app. Use the SFX option in winrar.

How do I combine my game.exe and "media" folder into one .exe file?

I've been searching for this for ages but no solutions. It's simple. I've created a C++ game. So I have a game.exe and next to it I have a folder named "media" from where the game takes all the images and sounds it needs. Now obviously when other people play the game I don't want them to see the media folder. I want to combine them into one .exe file. Can someone PLEASE explain to me how to do this like I'm five?
There are several ways to achieve your goal:
Simple add the content of your folder as resources to your project (http://msdn.microsoft.com/en-us/library/y3sk7e6b.aspx)
Create a resource-DLL (How do I create a resource dll) and link it to your project
In both cases the sounds and bitmaps will be not visible (binary) - that is what you want, isn't it?
It's not so obvious to hide the media folder, games often have a lot of folders.
In c# you can add pictures as resources to the project, so it gets embedded into the exe. There must be something like this in c++.

How to include all of a project's output in the installer project?

I need to include all the output from some of the programs projects in the installer... my question is similar to the one in this post: How to add a whole directory or project output to WiX package
However, I am afraid I don't really understand the answer given in this link. From all the reading I have done, I think I need to use Paraffin to do this. But is there a "start from the very beginning, how-to" resource for using paraffin?
I have read this page: http://www.wintellect.com/CS/blogs/jrobbins/archive/2008/12/22/paraffin-3-0-now-with-full-wix-3-0-support.aspx
and one of the posts mentions calling paraffin from a bat file. Is this how one would "use paraffin" in their installer? If it makes a difference, I have been using Visual Studio to work on this project, and am also not sure how to use command line from within Visual Studio. Does anyone have any resources for a very new beginner? Thanks.
I ended up including each .dll and .exe manually, since they don't change very often. It was fairly easy to format them in this style:
`<File Id="WhateverId" Name="NameToDisplayAfterInstall" Source="$(var.ProjectName.TargetDir)Filename.ext" />`
I used Excel to format a list of files quickly and easily. I put all of these File tags in the <DirectoryRef Id="INSTALLLOCATION">
tag.
I did figure out how to scrape all the dlls and exes from the project output by using Heat (not paraffin) and harvesting a directory, not a project. Harvesting a project yields only the main exe and dlls. The problem with harvesting a directory, at least in my case, is that I ended up with a lot of excess files, (like .pdb and .xml) that I didn't want.

Bundling a program and external files into a single executable?

This question is kinda similar to this one, but not exactly. I have a game engine in C#, and I'm working with some people who want to use my engine. Originally I designed the engine so that all the assets are external - non programmers can create art, music, xml settings, etc. and that anyone could modify an existing game, and share them amongst each other. Basically the whole thing including the engine itself is open source.
The group I'm working with (one of only two projects using my engine currently) wants to close their assets so they can't be modified. Although it's against my principle, I don't want to turn them away, both because I've already been working with them a while and because the market is very small (both for engines like mine, and for users of those engines).
The Actual Question
Is there a way, maybe some available software, that can take an exe and a bunch of other arbitrary files, and smash them into a single exe, that isn't just an archive? I would like the final exe to behave like it runs the first exe with some command line parameters that refer to the bundled files. For example, running bundle.exe would be just like running original.exe --project_path=/project but the project files are inside the bundle, and cannot be retrieved from it.
My original exe is written in C#. I doubt that matters.
You could pack these files as embedded resources.

Resources