Best way to create a standalone-exe (Forms) (C++) - c++

I have to create an application for testing that is relatively simple. If a user plugs in a device into a USB (hid library), the form will say "Pass". If no device is detected, it will say "Fail".
I want to create the app to run on WinXP+. It must be a forms application as it needs to be visual and have colors. The biggest requirement for me is that it must be stand-alone (a user just double clicks, the file and it opens, no installation). I need to avoid installing any extra .dll files and want to avoid the .net framework all together. It has to be written in C++.
So my question is, what are my options? I am new to Forms applications and the only forms application I have written required the .net framework.
From my research, Visual C++ seems out of the question as it requires .net for Forms apps. What about Turbo C++ by Borland? It seems outdated, but can it do the job?

I would suggest Borland C++ Builder 5 or 6. Visual C++ lacks the functionality to create C++ form apps, if we dismiss MFC

I'd say Visual C++ would probably still be your best option. A standard simple Win32 C/C++ program using only the native API will should suite your needs just fine. If you're targeting XP+, then the only dependency would be "msvcrt.dll" which is included with Windows by default.
Edit: This article on MSDN should get you started in the right direction.

What you're talking about is C++/CLI, it's microsoft's dialect of C++ that requires a .Net framework. Please distinguish it from real (native) C++, which can be used to create what you want to. Visual C++ is perfectly fine, just make sure you don't create a .Net project.

Forms are a .NET library. It's not Windows or anything like that, you can use the native GUI libraries in Win32 with no problem or any native wrapping of them. You can implement this in native C++ easily in Visual Studio.

If you're looking to create the application in a rapid fashion (i.e. stock UI components that you can drag and drop onto forms), my experience is that Embarcardero C++ Builder effectively solves that problem space.
I like Visual C++ but it's not a great environment for rapidly creating forms based applications. I want to emphasize that I'm referring to Rapid Application Development (RAD) tools. There are plenty of great C++ IDEs and libraries for creating forms based applications and all of them should be able to create standalone exes.
Here is a list of related questions that might help in your decision:
https://stackoverflow.com/q/1754020/4916
https://stackoverflow.com/q/93326/4916
Best C++ IDE or Editor for Windows

Related

How to run C++ executable in Windows PE?

I have an executable I made using a CLI console application with Visual Basic 2010. I can run the program completely fine from my developer machine.
However, when I copy the executable over to another machine, re-boot to a pre-installation environment and run the executable again, nothing happens at all. There are no errors shown or anything.
My guess is the executable can't run without certain dependencies that aren't loaded at this environment, but I need it to work in a PE.
Any ideas on whats going on?
First of all, since the question is tagged "c++" and you mention C++/CLI several times, I assume that "Visual Basic 2010" is a typo for "Visual Studio 2010". But either way, whether you've written the application in Visual Basic (VB.NET) or C++/CLI, the problem is exactly the same.
My guess is the executable can't run without certain dependencies that aren't loaded at this environment, but I need it to work in a PE.
That's exactly correct. You've written an application that targets the .NET Framework. Somewhat like Java applications requiring a JVM, .NET applications require that the .NET Framework be installed in order to run (or a compatible alternative implementation, like Mono). Unfortunately, Windows PE does not support the .NET Framework.
Note that it is irrelevant whether you've written a WinForms, WPF, or Console application. Although they present their UI in very different ways, they all depend on the .NET Framework being installed.
You will need to (re-)write the application in a different programming language, one that generates native code without any dependencies on the .NET Framework. C and C++ are popular choices. If you choose to use C++, make sure that you create what Visual Studio calls a "Win32" project. This is one that targets the underlying operating system APIs directly (i.e. a native application) and does not have a dependency on the .NET Framework. Stay away from anything that has ".NET" or "CLR" in its description.
I don't really have a full comprehension of when an application is using .NET or not... I am just used to Linux C/C++ development. I hate Microsoft shit
It uses .NET whenever you use the .NET Framework libraries/classes in your code. I'm not really sure why this is so difficult to understand. The same problem could easily exist on Linux if you were using a third-party library that was not available in certain environments for whatever reason. This is not Microsoft's problem, it's an issue of using the wrong tools for the job. The .NET Framework is an object-oriented wrapper around the native APIs that makes it much easier for people to get up and running writing programs for Windows. But if you're "used to Linux C/C++ development", you should have little trouble writing a simple console application that targets the native APIs directly without using .NET.
If your hatred for "Microsoft shit" has turned into an allergy, you can avoid Visual Studio entirely and download MinGW, which is a Windows port of the GCC compiler you're probably used to. Combined with your favorite Windows port of Vi, you're working in an environment very similar to the one you're used to. And since GCC doesn't support C++/CLI or the .NET Framework, you won't have to worry about getting stuck picking the wrong option.
The .Net framework has been supported as an optional package install during your PE build process for the past couple versions of WinPE. I write code in C# that I run in WinPE everyday. I have yet to find a good way to debug in a manner where I can walk through break points, etc... though. My best option has just been a lot of logging and a global Exception catch around my main entry point that will write out a full stack dump. You can attach to your app as a remote process in a VM running WinPE, but if you need to catch something early in the execution you'll have a difficult time.

What is win32 project in visual c++?

While I was creating a console application, I saw the win32 project. I created one and saw a bunch of code (which I supose is for creating the main window).Is this better then visual c++ winform application?If so why?
Is this better then visual c++ winform application?
No, it's different. "Better" depends on your goals.
A Windows Forms application will be a C++/CLI application, and use .NET. This may be "easier" for developing a GUI appilcation, but adds a lot of complexity and dependencies.
A Win32 application will not take a dependency on .NET, but then you can't use the .NET types. For details on what you can make when choosing that option, see MSDN's Win32 Application documentation.

How to create .NET independent apps using Visual Studio?

There exist many C++ IDEs. However, I find Visual Stuido (Visual Studio 2010 Pro) the most comfortable maybe because I've spent a lot of time with it. The problem is I really don't like .NET dependent products both speed-wise and compatibility-wise.
I guess there is no way to compile VB and C# codes without .NET dependency (please correct me if I'm wrong). In C++, is there a way to use VS IDE with all its functions like auto-complete, GUI design etc.. while keeping all the codes unmanaged so that .NET will not be required?
When you create a new project, if you select a Win32 project then it is a 'native' C++ application and does not depend on .NET. For existing projects, the relevant setting is Configuration Properties -> General -> Common Language Runtime Support. Set this to No Common Language Runtime Support to remove .NET dependencies.
Of course, the main UI designers for VC++ are the WPF and Windows.Forms designers - which depend on .NET components to implement them. If you don't want to use them, you're stuck using MFC for your user interface. It's not my idea of a good time, but many people do use it.

Developing windows forms applications?

C++ is by far my language of choice. However, I have only developed libraries and console applications.
I like how in Visual C# you can easily design a GUI for your application - simple drag-and-drop controls and edit their properties simply.
I have tried to create a windows form application in Visual C++, but it uses the CLR/.Net. Is there a way to make a windows form application in Visual Studio without having to use the CLR or .Net? I really love how easy it is to design a form application in C# or VB.NET.
Thanks!
No, the whole concept of a .NET application is that it leverages the .NET framework to do all the cool stuff you mentioned. If you were to elaborate on what it is you are trying to accomplish we may could recommend an alternative solution, but if you write a C# winForms application it's going to need the .NET framework to run...
EDIT:
You could use a qt ide, or possibly a QT plugin for visual studio. Check this thread out:
Best QT ide?

Can you build Winforms applications with C++?

I saw some Youtube videos that claimed they showed how to build a C++ applications using Winforms.
As far as I knew you needed something else like QT. Is it really possible to build using the same WinForms you would use to build a C# application but with C++ instead?
WinForms is managed code and is usable from practically every language with runs on the CLR. So standard native C++ can't build a winforms app. However managed C++ or C++/CLI can build WinForm apps in native code.
In general though I would question why you were doing this. If you are willing to have mixed mode C++ it would probably be much faster to
Build the UI in C#
Communicate with your native backend through a mixed mode C++ layer.
In VS ('05), you can go to File->New->Project... Then Visual C++ -> CLR -> Windows Forms Application. Have fun :)