c ++ add applications to Startup on linux programmaticaly from inside program code - c++

I am trying to find how in c ++ whitch add current application at Startup on linux programmaticaly from inside program code.
Suppose we have the "Hello world" as a program that opens in Mint user session.
When Hello World starts, must find if there is link in startup applications, and if is not to add link, so next time opening user his profile to see the "Hello world".
Is it possible to do this without system scripts, only with c++ std library?

The problem is not a C or C++ problem, rather you should consult the session manager's documentation of your distro, for example, if you are using gnome, you could create a startup file under $HOME/.config/autostart, and put the program path in the startup file.
There is a wiki listing how to manager autostart programs for many desktop environment:
https://wiki.archlinux.org/index.php/autostarting

Related

Launch command line programs behind all open windows from a C++ executable

I am working on C++ program in windows which launches numerous external programs using command lines in quick succession after previous one finishes. Currently a new terminal pops up in front every time I make an external program call. I have tried SYSTEM an POPEN. Is there a way to launch these terminals in the back behind all open windows so that its not annoying to the end user who may be working on other stuff?
One solution is listed here but doesn't work for me as it still pops up terminal in the foreground.
c++ run system() in background, with spaces in dir path, + output to text file
system("start \"\" cmd abcd.exe");
Unless you really need to use system(), I would recommend using ShellExecuteA, if you set nShowCmd to 0, it doesn't generate any windows or pop up any consoles.

Difference between 'Windows Console Application' and 'Empty Project' in VS C++

If I'm making a simple C++ program, such as connecting to a database, which option should I choose in Visual Studio 2017 as a Visual C++ template?
Windows Console Application
or
Empty Project?
Will a Windows Console Application based program run only on windows where as an empty project one will run on many OS'?
A "Window's Console Application" program has stuff added to your project to make it run smoother with the Window's command prompt. However, even if you create an "Empty Project", the compiled version will not run on another OS, by default. You will have to recompile for each OS you want to work with.
Use a console application, it will already have the main function and such in there. It is what you would use for a "hello world" program.
If you start from an empty project you're just going to have to create a similar .cpp file anyway.

C++ disallow command prompt from displaying

Is there any thing I can do to make sure that the shell/command prompt does not show up when I run my C++ program, it is meant to be a background program? While it isn't a huge deal if it displays because it quickly closes, I would prefer it doesn't display at all. Program will run on windows xp/vista/7 OS
Configure your compiler or linker to mark your program as a GUI application.
Windows recognizes two main types of programs: GUI and console. If the EXE header is marked as a console program, then the OS creates a console window prior to executing it. Otherwise, it doesn't. This isn't something you can control at run time; you need to set it at link time. (You can call ShowWindow(GetConsoelWindow(), SW_HIDE) to try to control it at run time, but that doesn't prevent the window from flickering on and then off again. Plus, if your program is sharing the console with another program, like cmd.exe, then you'll have just hidden the user's command-prompt window!) Even if your program doesn't have any actual GUI, that's still the mode you need to avoid having a console window created for you.
If you're starting a new project in Visual Studio, select the "Win32 Console Application" option. If you already have a project, then in your project's configuration properties, find the "Subsystem" setting of the "Linker/System" section and set it to "Console." That makes the linker use the /subsystem:console option. If you're using Mingw, use the -Wl,--subsystem,windows option.
Sounds to me like you want to create a Windows service, not a command line utility. This is why services exist. Long running background tasks that require no user interaction. A simple example here.

AIR NativeProcess API

I use nativeprocess api in AIR to launch a c++ console app. The console app runs correctly but does not appear, but I want it to be visible and user be able to interact with it. How can I achieve that?
Instead of launching your executable directly, you'll need to launch your platform's terminal application (on Windows, that's CMD.exe, on OS-X it's Terminal.app, and on unix/linux it's xterm).
By default, the terminal application will run an interactive shell prompt, but you can use command-line arguments to tell it to execute any other program instead. In this case, you'll want to tell it to execute your C++ console application.
On Windows, this might look something like this:
CMD.exe /K C:\path\to\your\app.exe
on OS-X, it's a little more complicated. Here's a related S.O. post ( Running a command in a new Mac OS X Terminal window)

Application launch from c command in window OS

I want to make an console application of c which can run other applications (exe files). Kindly guide me how can I make it possible so that from my c code i can run other executable files in window OS.
You can use the CreateProcess Windows API function.