Ajay Kokill
Ajay Kokill

Reputation: 1

Shell function in c programming just like in visual basic

Can anyone tell me what is the code in c programming for the shell function just like in visual basic it is:

Shell("C:\WINDOWS\CALC.EXE", 1)

Thank You

Upvotes: 0

Views: 79

Answers (2)

Rohan Bari
Rohan Bari

Reputation: 7726

You can try system() function in C.

An example:

system("calc.exe");

Edit: You need to use an escape sequence for representing a backslash, because it itself represents the starting point of defining an esc. sequence (e.g. \n), use \\ wherever you need to append \. For example:

system("My\\Long\\Long\\Path\\program.exe");

Upvotes: 0

Lundin
Lundin

Reputation: 213810

I believe the VB function is just a simplfied wrapper around Windows API ShellExecute.

The equivalent C code would be something like:

#include <windows.h>

ShellExecute(NULL, 
             NULL, 
             "C:\\WINDOWS\\System32\\CALC.EXE",
             NULL,
             NULL,
             SW_SHOWDEFAULT);

Upvotes: 3

Related Questions