I am trying to test using ShellExecute to open chrome on the initialisation of an MFC application. This is the code I am implementing:
HINSTANCE a = ShellExecute(NULL,"open","C:\Program Files\Google\Chrome\Application\chrome.exe",NULL,NULL,SW_SHOWNORMAL);
But the functions returns the value 2
to a
. I checked online and found that this corresponds to the file not being found, but I rechecked the path and it is correct. I also read that this could be because of the executable being administrator accessible only, but I checked this as well and it isn't. I tried using CreateProcess
but it too was not working.
Have I understood the function wrong, or am I using it wrong? Am I missing a header? Also is it possible to open chrome and open a bookmark?
EDIT 1: I changed the backslash usage in the string literal to the following
ShellExecute(NULL,"open","C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",NULL,NULL,SW_SHOWNORMAL);
Am I supposed to do the same for the colon as well? Because the function is still returning 2
.