Link to home
Start Free TrialLog in
Avatar of Sub_Main
Sub_Main

asked on

eqvivalent for VB "Shell Function"

i'm VB.
i'm looking for MFC\VC++ eqvivalent for VB Shell Function.
this function activates any application from the current code.
examples :
Shell "path To App EXE",windowMode(Constants available)

or :

Shell "pathToDocFile_pathToWinword",WindowMode

etc...

knowing no eqvivalent in MFC\VC++, i've tried to include the
Proccess.H lib, and used :
system("ApplicationPath");

that's works fine only when the path is in the same dir :

system("abc.exe");
system("abc.msi");

this one is not executing (the path is correct) :

system("I:\Program Files\Project1\Project1.exe");

this line raise 3 warnings :
warning C4129: 'P' : unrecognized character escape sequence

i suspect it's the Slash or space in folder name or long folder name.

another thing i've tried is a batch file. that's fine exept that it don't get a folder name like "Program Files"

anyway, i need an MFC\VC++ solution as simple as VB....

thank you.
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
By the way, the warning error is due to the escape character '\'. It should read

system("I:\\Program Files\\Project1\\Project1.exe");

::ShellExecute(hWnd, NULL, _T("c:\\dirname\\abc.exe"), NULL, NULL, SW_SHOWNORMAL);
Avatar of Sub_Main
Sub_Main

ASKER

does compiling it with MFC lib linked  - will make the EXE run on any machine without instllation ?

i mean, in VB - if you just create an empty project - you have to install all VB runtime DLLs on the target machine.
i want to use MFC in order to distribute only the EXE by copying it.
will it work under any 95\98\NT clean fresh machine ?
ShellExecute is a Win32 API function, meaning that it is available on any Windows 95, 98 and NT. Actually, even Windows 3.1 supports it.
tnx