![]() |
question about c.
I'm pretty new to c programming so plz dont flame me if this is a newbie question but is there a way u could open a different program with an .exe extension w/ a c program.
like for example would this work? fp = fopen("file.exe", ??); ty for your help |
This is C, a computer language...Anything will work, you just have to know how to devise the right scripts. There is a way for all.
|
That would open the file. The question is if opening the file is really what you want to do.
|
Well I run bots on my computer all day when I'm not at home and the new one crashes quite a bit. I was wanting to make a program that would just restart it for me everytime it turns off. This is my script:
#include <stdio.h> FILE *fp; int main(void) { fp = fopen("mephbot.exe", "???"); if(fclose(fp)) { fp = fopen("mephbot.exe", "???"); } return 0; } I was thinking that would do it but it does absolutely nothing...doesn't even start my program. Mephbot.exe is the name of the program I did check that and where I put the question marks I have tried many differen combos. Any help as to why this is not working would be helpful...thnx |
VB is much nicer for writing these kind of programs, if you have it, Ill tell you how to write it.
|
You want to execute, not open the program. I can't help you on that one if you're trying to do it in a DOS program. If you can use the windows API, look at ShellExecute and ShellExecuteEx .
And if you have computers with compilers at school (read CS lab), and they have VC++, and they have fortress or some other lock out program, I have the source for a very interesting, um, utillity that I wrote, that can, um, supliment the run box by convincing windows that text files are really executable without renaming them, yeah. (In other words, this source turns VC on a computer into a nice way to run WinAmp and such on computers that wouldn't normally allow it) |
mjordan2nd: Tells us what compilers you have; straight c is old, and hard to work with.
|
i have dev-c++ compiler.
|
mjordan2nd: Try this, should work in any c compiler that supports Win32. It'll run Notepad untill you quit it via the taskmanager.....
#include <windows.h> int WINAPI WinMain(HINSTANCE handle,HINSTANCE dontcare,PSTR cli,int showflags); int WINAPI WinMain(HINSTANCE handle,HINSTANCE dontcare,PSTR cli,int showflags) { STARTUPINFO startup; PROCESS_INFORMATION process; GetStartupInfo(&startup); /* Just copy the current process startup info. */ do { if (!CreateProcess("c:\\WINNT\\System32\\NotePad.EXE" ,NULL,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,N ULL,&startup,&process)) { MessageBox(NULL,"Can't launch app.","Applauncher",MB_ICONWARNING|MB_OK); exit(1); /* can't create process, die. */ } WaitForSingleObject(process.hProcess,INFINITE); /* Wait for the process to die. */ } while (1); return 0; } |
thank u mr rooster...ill try it and c if it works, never done any windows programming so ill c...thank u
|
All times are GMT -6. The time now is 09:04 PM. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
This site is best seen with your eyes open.