What's the easiest way to generate a PE32+ executable? - cross-platform

I'm currently working on a library that reads PE32/PE32+ binaries, and I need to generate a sample PE32+ binary so that I can read the headers as part of the library tests. Assuming a simple "Hello World" application, what's the simplest way to create both a PE32/PE32+ binary executable using the same source code?

The simplest way would be to create a "Win32 console application" empty project with Visual Studio, add "64-bit" configuration and compile both 32-bit and 64-bit executables. This will require 64-bit Visual C++ compiler installed in Visual Studio which is present starting with Visual Studio 2005 but is not installed by default.

Related

How do I point CodeBlocks and Visual Studio Express 2008-2012 to custom Include and Lib directories?

This is a tricky question... I have put together a compilation of DirectX, OpenGL and Windows SDK Include and Lib files into a single directory called, "AllCode." Inside that are Lib and Lib/x64 Directories, and an Include Directory. Essentially everything from DirectX 7 to now is in there. You can check out the page I have this on here:
http://hi-techheadache.blogspot.com/p/blog-page.html
The point of this is to make it easy to compile and run code from any book. I want CodeBlocks and Visual Studio Express 2008-2012 to be pointed, as it were, to my AllCode directory, so that anytime it needs to refer to any of those files it can. I don't want any errors from missing files! I want to code something from a book like, "Programming A Multiplayer FPS in DirectX" by Vaughan Young and expect that it will compile, link and run without issue! How do I set each IDE up for this?
BTW I'm on a Windows 7 64-bit machine. All drivers updated and installed. Running the latest version of CodeBlocks, Visual Studio Express 2010 SP1 and Visual Studio Express 2012.
You can create an empty project that specifies the required settings. You want to specify include directories, and add libraries to be passed to the linker. You can save the project somewhere, and then make a new copy of it every time you need to start a new project. You could even include some boiler-plate code if appropriate.
Certainly on Visual Studio you can take this approach further and convert the project into a fully fledged template that appears in the new project dialog: http://msdn.microsoft.com/en-us/library/vstudio/s365byhx(v=vs.100).aspx. I expect that CodeBlocks has similar functionality.

Can you create a .exe with Visual Studio

I know that visual studio has A LOT of required files to launch anything through an executable, is there a way I could create an .exe that doesn't require all the excess files like you would with a JAR file? I know they are completely different but I'm just trying to find out what we can do other than installing the application on the users PC. Thanks!
is there a way I could create an .exe that doesn't require all the excess files like you would with a JAR file?
Partly. If you're using VB.Net, you will always need to verify that the machine where you run your executable has the .NET Framework version which you target.
Most systems already have some .NET versions installed, which will allow your .exe to "just work" (provided you don't use any libraries apart from the framework). Targeting an older .NET framework (like 3.5) will allow your exe to work on any system with .NET 3.5, without any other files.

Win32 Project (API): Compatibility with other version of Windows

I use API to make a programs. It runs pretty well on Windows 7 (with debug file .exe), but it doesn't when I run it on Windows XP. Are there any ways to solve this problem?
I suppose you are using Visual C++, according the the message you get.
Your project is set up (by default) to link the Microsoft C++ Runtime Librairy dynamically, so it saves up space in your final executable, but you need the dynamic linked libraries to be in your system or in your executable's folder.
To solve this in Visual C++, without any afford from who are executing the program in their machines, you can change how MSVC link their runtime library to your executable, that is, if you set it to be linked statically, all the dependencies will be linked inside your final .exe, with no need of additional .dlls.
To change this option, refer to /MD, /MT, /LD (Use Run-Time Library) - MSDN.
Or in short: Project Properties>Configuration Properties>C/C++>Code Generation>Runtime Library
If in debug mode, use /MTd, otherwise use /MT.

How to serialize a class in MFC for win7?

How to serialize a class in MFC for win7 ?
My computer is win7 operation system, and install vs2008. if the code, which include serialize a class and create a backup file, program the code as a execution File and run it in my computer is OK, it can open the serialized file and load data. but if the other win7 computer which not install vs2008, the execution File can not open the serialized file and load data is not success, but run in xp system is success.
I want to make my program can run win7 and xp,how to do it? thanks very much for everyone.
If you are placing your file in "non-appdata" folder, perhaps you are having problems with UAC. You can check for a possible solution here
Are you trying to use the DEBUG version of your program?
When you create a MFC program under Visual Studio, it creates a project that is 32-bit and uses the DEBUG version of MFC and the Runtime library. When you get ready to distribute your program, make sure you build the RELEASE version which uses the non-DEBUG versions of MFC and the runtime library. In all likelihood, the VS2008 runtime libraries will already be on your target Windows 7 computer. If not, the user will have to download and install the Visual C++ 2008 runtime files from Microsoft.

How to create DLL library on Windows with WxWidgets?

I'm looking for a simple example how to create a DLL library on Windows with WxWidgets.
I need use some wxWidgets API on DLL and it'll called from Delphi.
There is the "dll" sample showing how to do it in your wxWidgets directory or you can view it online at https://github.com/wxWidgets/wxWidgets/tree/v3.1.0/samples/dll
I think the easiest way is to install the free Visual C++ Express Edition, compile the DLL with that (Visual Studio project files are provided with WxWidgets). If it still works like in the old days, then you will also have to import the library for use in delphi with with the implib command.