Newby - very simple program that don't work

S

Stefano

I have a couple of lines of a program that are making me mad.

My intention is to run Internet Explorer in background.

#include <windows.h>
#include <stdio.h>
int main ()
{
char* strFunct = "c:\\Progra~1\\Intern~1\\iexplore.exe";
WinExec(strFunct,SW_HIDE);
return 1;
}


I can see the process iexplore.exe running with Task Manager, but after
5 -10 minutes the process is halted by the system apparently without any
reason. Same thing using CreateProcess instead of WinExec.

The problem seems to be the use of SW_HIDE with iexplore, because using
instead SW_SHOW the process never stops.

Is there somebody that can help me ?
The program is running under Windows 2000, the compiler is Visual C++ 4.0
and Explorer 6.0.

Thank you very much.

Stefano
 
A

anon

Stefano said:
My intention is to run Internet Explorer in background.

#include <windows.h>
#include <stdio.h>
int main ()
{
char* strFunct = "c:\\Progra~1\\Intern~1\\iexplore.exe";
WinExec(strFunct,SW_HIDE);
return 1;
}


I can see the process iexplore.exe running with Task Manager, but after
5 -10 minutes the process is halted by the system apparently without any
reason. Same thing using CreateProcess instead of WinExec.

How did you compile it? I got this:
w.cpp:1:21: error: windows.h: No such file or directory
w.cpp: In function 'int main()':
w.cpp:6: error: 'SW_HIDE' was not declared in this scope
w.cpp:6: error: 'WinExec' was not declared in this scope
The problem seems to be the use of SW_HIDE with iexplore, because using
instead SW_SHOW the process never stops.

I haven't seen those so far.
Is there somebody that can help me ?

Maybe.
 
S

Stefano

Stefano said:
How did you compile it? I got this:
w.cpp:1:21: error: windows.h: No such file or directory
w.cpp: In function 'int main()':
w.cpp:6: error: 'SW_HIDE' was not declared in this scope
w.cpp:6: error: 'WinExec' was not declared in this scope

1) Open Microsoft Developer Studio
2) File -> New -> Text File
3) Paste the code
4) Save as w.cpp
5) Build -> Rebuild All
6) The message appers: "The build command requires an active workplace.
Would you like to create a default project workplace ?" Select yes.
7) w.exe is compiled with 0 errors and 0 warnings.

I haven't seen those so far.

See WinExec function http://msdn2.microsoft.com/en-us/library/ms687393.aspx
and nCmdShow paameters:
http://msdn2.microsoft.com/en-us/library/ms633548.aspx


Thank you.
 
G

Guest

I have a couple of lines of a program that are making me mad.

My intention is to run Internet Explorer in background.

#include <windows.h>
#include <stdio.h>
int main ()
{
char* strFunct = "c:\\Progra~1\\Intern~1\\iexplore.exe";
WinExec(strFunct,SW_HIDE);
return 1;
}

Sorry, Windows programming is off-topic in this group, try a win32
programming group instead.
The program is running under Windows 2000, the compiler is Visual C++ 4.0
and Explorer 6.0.

Are you sure you are using VC++ 4? Every now and then someone is using
VC++ 6 and the advice to them is usually to get something newer since
VC++ 6 is very old and buggy. VC++ 4 must be ancient by now, and it is
questionable how good it is at compiling C++ programs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top