C/How to create an exe file?
Expert: Prince M. Premnath - 8/24/2006
QuestionHello Sir,
Mahesh here again. Can i get the code for how to resart the computer using c? Yes i'm using tourbo C/c++ compiler. Does code or meaning differs if it is borland compiler?
I would like to ask onething that is restarting means executing the last statemnt of O.S & restarting. Does it's process is similar to shutdown?
I would like to ask 1 more Ques?
Can we delete a file using C/C++?
-------------------------
Followup To
Question -
Hello sir,
Suppose I created a small program in C. I would like to create an exe of this file? how to create it? We have to do it by coding or an external way is used?
Another Q is - How to shutdown a PC using a C program?
Answer -
NOTE : I assume that you are using TURBO C/C++ compiler.
You cant create EXE file on your own just like coding other programs , usually EXE files will be created by the compiler after giving the "Run" command in the main menu.
How to compile?
First type and save your program with .C Extension from your TURBO C/C++ IDE ( Integrated Developing Environment).
use the shortcut key "ALT+C" to compile , then a message box will show you "Errors / Warnings / success " if its display "Success : Press any key" then your program is ready to run .
How to run a program?
After compiling press "ALT+R" to run the program.
2nd QUE.
You can't do that using C!
Its a big concept if you know little bit about operating systems you can understand my answer!
Before executing all the programs (Including Operating system Programs) should Load into the Main Memory , after it executing the last statement the program removed from the Main Memory , you may know very well an operating system is also a program loaded into the Main Memory after switching ON the system. The "SHUT DOWN" Process simply divert the control of the execution to the last statement of the "Operating System Program" ( After taking some essential steps ) the system will show you "Its now safe to turn off the computer".
Note :
You can RESTART the computer once again using C!
( If you wish to know about that just ASK A FOLLOW UP - "DONT
HESITATE !")
AnswerYa! We can delete a file using c Program , it can be done with the help of the standard C Library function "remove()" available in stdio.h , which removes the file compleately from disk, general format is "remove("SAMPLE.DAT");"
2, You can restart the computer by execuiting the ROM-BIOS Function available under interrupt number hex19.
sample code:
#include<dos.h>
void main()
{
/*Program to restart the computer */
geninterrupt(0x19);
}
NOTE:
Make sure this code will work only if your operating system is in MS-DOS mode , otherwise it won't work.
3, how to make an exe file?
We can't create EXE File on our own , its the duty of the compiler. if you wish to create your own EXE file? then
1.,Study about the fundamental principles of COMPILER
2.,Write your own compiler
3.,and let the compiler to create the exe file depend no your MACHINE.
There is lot more with C ! To know about TSR Programming Just ask me a follow up "its time to learn more".