How to release a C++ program?


I have recently made a small program in C++ which prompts the user for yes or no and then if its a yes, the program will shutdown the computer. I made it because I hate the way you have to turn off windows 8.
I made this program in MS visual ultimate 2012 and I tried to search on the internet about how to release a C++ program but I could find anything.

I am a beginner so I'm still learning C++. Basically I want to make a program that will install my program on a computer running windows, so its doesn't have to be complicated. I've just found where I saved my project and copied the 'Debug' folder and pasted it in program files on the C drive and got the application file that starts the program and out it on the desktop? Is that right? - I know this isn't really installing it but it does work.
Remember I am using MS visual ultimate 2012.

Another problem is I am using the code: system("shutdown -s -t 1"); and I have read that this system() is evil and really bad to use as it causes big security holes; is there any other way that I can tell the computer to shutdown or is that code ok?

If you want me to post my C++ source code of the program if you need it, just ask.

Last edited on
I would use the function ExitWindowsEx

Maybe look something like this

#include <windows.h>
#include <iostream>

int main()
    char shutdown = 'y';
    std::cout << "Shutdown(y/n)? ";
    std::cin >> shutdown;
    if( shutdown == 'y' )
    return( 0 );

I will test the code and let you know if it works.

*edit forgot the reason testing now
Last edited on
Yeah I came across the function ExitWindowsEx but it was going on about inputting values and other parameters, I didn't understand it so I didn't use it.

But you've got the ExitWindowsEx( EWX_SHUTDOWN | EWX_FORCEIFHUNG ); as a beginner I probably should tackle this now but like I said before I tried to use and that was the website I found, I do want to use it but just could not get it to work with all the _In_ and values you have to do.

Thanks and ok.
Last edited on
I haven't used the function before but it looks like you have to give it privilege to shut down first.
Yeah I found the code to preform a shutdown and just copied it from that Microsoft web page, Ill let you know if it works if you want.

Thanks for your help, really didn't want to use that system(); after reading about it.

Also, do you know a way that I can make a program that can install my program?

Thanks again!
You want to compile your program. You also do not need to write an installer. Intallers generally set up registry values, create the folder directies for the program, etc... but you're writing somthing small that doesn't need to create any files and such (i assume). Even if it did need to create files it isn't necessary to write an installer.

You can just copy/paste the binary anywhere to use it.
Well the code on stack overflow definitely works lol.
Hey I just noticed you have both answered some of my other question before lol.

Yeah I compiled it and it works, yeah ill leave out the installer then.
Thanks for the advice.

What do you mean by
You can just copy/paste the binary anywhere to use it.

Thanks guys.
When ever you compile a program in C++ it creates an .exe file.

To get this file to run you need to include all the .dll files it is dependent on.

When compiling pay attention to what files are used. My compiler says something like "symbols loaded" next to a .dll file name.

Make a copy of these .dll files and include them in the same folder as your .exe file. Then you are good to go.

Now if you want to install... you should move the .dll files into the system directory. On my computer it is called system32. If the .dll files are in this folder then your .exe file will also work.

One easy way to move the .dll files into the system folder is with simple batch comands. I like to create an install.bat file for this. Then an end user just clicks on that file and it is done.

I once played around with something called NSIS installer. It is free but complicated and not always working right.
Thanks for the information Manga, I will take a look at that NSIS installer.
But as my program is very small I will probably look into that batch installer.
If you are familiar with using DOS prompt, it is just a collection of DOS commands.

Just use notepad and create a text file. Then rename it to somename.bat.

Here is an example of one I have used... called install.bat

move msvcp100.dll c:\windows\system32
move msvcr100.dll c:\windows\system32
echo installation complete

Its done baby!
You could also make the shutdown program the same way. You can actually hide the shutdown bat command in image files and stuff too not that you would need to.
Oh right interesting.
Might have a go at it.
Wow, still got a lot to learn though ;)
I made the shutdown program with a nice power button from icon archive; search it on Google if you have never heard of it.
Probably have but oh well.
Topic archived. No new replies allowed.