Search This Blog

C Program to Hibernate Windows

Do you want to hibernate your Windows computer from c? This is a c program to hibernate Windows operating System. If you execute this c program, it will hibernate your Windows computer instantly. The following is the c code to hibernate Windows:

//C Program to hibernate Windows
#include
void main()
{
system("shutdown /h");
}

C Program to Run Applications to Open a File in Windows

In this post, we will see how to run an executable to open a file. This will tell you open a file with specified application. This can be used like the open with option in operating systems. To open a file, most applications, are launched with the path to the file as command line argument (command line parameter). The following c program will open paint with a command-line argument. mspaint command opens paint. Or you can use "C:\\Windows\\System 32\\mspaint.exe". The exepected command-line argument to paint is the path to an image file. Then the paint application opens that file as image if possible.

#include
void main()
{
system("C:\\Windows\\System32\\mspaint.exe \"C:\\Users\\Shareef\\Desktop\\flower.jpg\"");
}

The above c program will open the image flower.jpg using paint application in Windows

C Program to Launch or Execute an Application With Command Line Parameters

In this post, we will see how to run an executable with command line arguments. This will tell you how to execute any application with command-line arguments using c code. The following c program will open paint with a command-line argument. mspaint command open paint. Or you can use "C:\\Windows\\System 32\\mspaint.exe". The exepected command-line argument to paint is the path to an image file. Then the paint application opene that file as image if possible.

//How to run applications with command line arguments in c
#include
void main()
{
system("C:\\Windows\\System32\\mspaint.exe \"C:\\Users\\Shareef\\Desktop\\flower.jpg\"");
}