Click here to Skip to main content
15,887,446 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hellowm I think this question is quite simple.
How to execute a external program in C++?
I cant use the ShellExecute() Function it displays an error message...
Error Message:
Error 25 error C3861: 'shellexecute': identifier not found d:\files\antivirus\gui\gui.cpp 331

MS Visual Studio 2005 C++

Is I use the system() dunction my application will hung! :(

I dont know what to do! Please Help me!
Thank You in advanced!
Posted

PROCESS_INFORMATION piInfo;

CreateProcess(_T"function path goes here",NULL,NULL,NULL,FALSE,NULL,NULL,NULL,NULL,&piInfo);


You can try using createprocess as above.

MSDN link :
[^]
 
Share this answer
 
v4
Comments
sora97 18-Apr-11 5:25am    
sorry but it displays another error message
Error 25 error C2664: 'CreateProcessA' : cannot convert parameter 1 from 'const wchar_t [21]' to 'LPCSTR' d:\files\burn_prj\my programs\gpm antivirus\gpmav-gui\clamav-gui.cpp 339
Guyverthree 18-Apr-11 5:31am    
Sorry i use mobile programming alot and that defaults to Wide string.

Remove the L from the front of the path
sora97 18-Apr-11 5:37am    
ok
Aamir Butt 18-Apr-11 8:47am    
A better solution is to use _T instead of L. This will make sure that a string is according to the project settings. In the above code, it would be: _T("function path goes here")
Guyverthree 18-Apr-11 9:09am    
Aamir Butt is correct I should have used the macro instead of the L parameter.
I have changed the solution to improve it.
To get ShellExecute[^] to compile, you have to #include <Shellapi.h>
That will rid you of the C3861 error.
 
Share this answer
 
Comments
Guyverthree 18-Apr-11 9:10am    
this does fix the issue +5
Manfred Rudolf Bihy 18-Apr-11 9:46am    
Good answer! 5+
[Adding to the other answers here]

See A newbie's elementary guide to spawning processes[^]

Wrote that some years back. Should be still relevant.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900