Skip to main content
GameDev.net gamedev.net
🔒 Locked

[C++] Adding another executable as 'resource'?

Started by Decrius Jan 26, 2008 at 9:11 AM 0 replies 3.3k views
Original Post
Decrius
Decrius
Hi, I made a small program which uses 7-zip for compression. However, I don't want to publish my program as 2 executables, but I want to 'merge' them, so that 7za.exe is not visible and not directly usable for the user, but only my program (which is actually a 'user-friendlier' version of 7za.exe). Can I just add 7-zip as resource or something? Or use something like this: http://www.erikveen.dds.nl/eee/. Or would it be better to compile the 7za source into my own project? Tried that, but my MingW compiler gives me some errors of the Visual Studio project of 7z (I use CodeBlocks, which imports VS project files. I could just compile it (some warnings, 2 errors) but apparently VS compiler and GCC compiler work a little different). I prefer the last option (compile 7za into my project), as I than can get rid of the unwanted output 7za generates, but I have no idea what to do with the errors. Errors: resource.rc
MY_VERSION_INFO_DLL("7z Plugin", "7z")
syntax error It includes "MyVersionInfo.rc", which has the following content:
#include <WinVer.h>
#include "MyVersion.h"

#define MY_VER MY_VER_MAJOR,MY_VER_MINOR,MY_VER_BUILD,0

#ifdef DEBUG
#define DBG_FL VS_FF_DEBUG
#else
#define DBG_FL 0
#endif

#define MY_VERSION_INFO(fileType, descr, intName, origName)  LANGUAGE 9, 1 1 VERSIONINFO   FILEVERSION MY_VER   PRODUCTVERSION MY_VER   FILEFLAGSMASK VS_FFI_FILEFLAGSMASK   FILEFLAGS DBG_FL   FILEOS VOS_NT_WINDOWS32   FILETYPE fileType   FILESUBTYPE 0x0L BEGIN     BLOCK "StringFileInfo"     BEGIN          BLOCK "040904b0"         BEGIN             VALUE "CompanyName", "Igor Pavlov"             VALUE "FileDescription", descr             VALUE "FileVersion", MY_VERSION              VALUE "InternalName", intName             VALUE "LegalCopyright", MY_COPYRIGHT             VALUE "OriginalFilename", origName             VALUE "ProductName", "7-Zip"             VALUE "ProductVersion", MY_VERSION         END     END     BLOCK "VarFileInfo"     BEGIN         VALUE "Translation", 0x409, 1200     END END

#define MY_VERSION_INFO_APP(descr, intName) MY_VERSION_INFO(VFT_APP, descr, intName, intName ".exe")

#define MY_VERSION_INFO_DLL(descr, intName) MY_VERSION_INFO(VFT_DLL, descr, intName, intName ".dll")
(when I escape the line, I get the next error:) Threads.c
HRes CriticalSection_Init(CCriticalSection *p)
{
  /* InitializeCriticalSection can raise only STATUS_NO_MEMORY exception */
  __try 
  { 
    InitializeCriticalSection(p); 
    /* InitializeCriticalSectionAndSpinCount(p, 0); */
  }  
  __except (EXCEPTION_EXECUTE_HANDLER) { return SZE_OUTOFMEMORY; }
  return SZ_OK;
}
'__try' undeclared Thanks in advance, Taco
[size="2"]SignatureShuffle: [size="2"]Random signature images on fora
Evil Steve
Evil Steve
I don't really follow what the problem is. Firstly, I'd strongly recommend switching to Visual Studio. It's free to download, can do everything MingW / CodeBlocks can do, and has an almost infinite more amount of support.

As for embedding EXEs as resources, there's nothing special about it. You can just add it as you'd add any other binary / custom resource. You won't be able to execute it from memory (Well, there are ways but they're extremely complicated, require an in-depth knowledge of the EXE file format, and aren't portable to other OSs), you'll have to extract it to a temporary file and then run it from there, and delete it once you're done.

__try, __catch and __except are used in Structured Exception Handling (SEH), which is specific to Visual Studio. So you almost certainly won't be able to compile that code in another compiler.

Also, off topic - it's advisable to use [ source ] tags rather than [ code ] tags for long or wide source snippets, since they don't break the forum tables.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.