I am trying to write a icon changing program like resource hacker. I am able to change icons of windows programs but not console programs and I think thats quite obvious. So I want to write a code in my program that will check if the argument exe file is a console program or windows program before it tries to change the icons.
So how do I check if an exe file is a console program or windows program. I am writing program in C using visual studio.
The Subsystem value inside the Portable Executable header of the file will give you the info:
WINDOWS_CUI 3 Runs in the Windows character subsystem (a console app)
Related
I need my C program to run in the background, so without any open window or without blocking the terminal if run from there.
I can't find much info on how to do it online.
edit: To do what i needed, i just added -mwindows to the gcc command.
Windows supports two program types; GUI and console.
Console applications automatically get a console window if the parent process does not already have one.
GUI applications do not get a console and they can have 0, 1 or multiple windows. If you don't create a window your application is basically only visible in Task manager. GUI applications typically use WinMain as the startup function instead of main. Notepad.exe is a GUI application that creates a window.
You need to tell the compiler/linker that you are creating a GUI program. If you are using Visual Studio, it probably has a project template you can use.
I have written a very simple C program with a GTK interface that has allows the user to load an input file.
On some Windows 10 computers, the program crashes without showing any error window while trying to read the input file. But on other computers, it reads files just fine.
Is there a known cause for this kind of inconsistent behavior on Windows?
I have made a c program with codeBlocks on windows 10, but the exe crashes as soon as I open it, actually it does not matter the program all exe produced by codeblocks won't run, maybe there are some problems with the settings? Cause if I run the program from inside codeBlocks it runs without problems, any suggestion?
You are compiling "command line programs", which don't open a window on their own. Since they apparently don't expect any user input they run to the end quite happily and quit.
If you want to run this type of programs, you need a shell, which provides a window.
This is a simple way to get one: Open a file explorer window and navigate to the directory containing your program. Click into the address bar so that it changes into a textual representation of the path. Replace all of it with the word cmd and press enter. Now the shell's window opens, commonly with white text on a black background. Enter the name of the program, and it will run.
I am using eclipse cdt oxygen with mingw64 7.2.0 on windows 10 to write programs in c. Whenever I write programs that only outputs like:
printf("x\n");
The output got printed into the console. However when I write programs that asks for inputs, like:
c = getchar();
rather than going to the console, eclipse instead opens a terminal. I believe that is where you will type the input. This doesn't usually bother me, however my eyes are destroyed, I am using a screen reader and this terminal is somewhat inaccessible. It is usable, but can be very hard to use sometimes (E.G. my screen reader JAWS does not speak what I'm typing).
Is there a way for eclipse cdt to put all inputs and outputs directly to the console?
Unfortunately in this case eclipse console is read only. Better once compile and build your code go to the folder where it created your exe file and run that exe in command prompt and test.
open command prompt window (type cmd)
cd C:\path_to_your_exe\
yourexe
This will also help you in case your program takes command line parameters.
I made a program to connect to a device via Bluetooth and send the data to the web using pure C in gcc. I won't be able to implement any GUI portion in the code right now but I need to deploy it to test users for testing. I want to have the executable with an icon so that a user can click on the executable and the program starts in the terminal. How do I add an icon to the executable and start the program in the terminal?
Sorry I failed to mention before that its in Ubuntu Linux
This document explains how to add your program to the programs menu: http://standards.freedesktop.org/menu-spec/latest/.
If this is a Windows executable you're making, what you need to do is to use a resource compiler to make an object file that includes the resources you want (an icon in this case) which you can then link into your program as normal. The resource compiler I've used when building programs on Windows with gcc was called windres.
I found it to be very finicky when dealing with directories with spaces in the name. Beware!