# Thread: ShellExecute() behavior

1. ## ShellExecute() behavior

Hello. I'm using ShellExecute() to launch a document file in its default application. However, the function just opens up the file's directory in explorer instead. Assuming that I'm calling the function correctly (a bold assumption), what could be causing this?
Code:
```ShellExecute(NULL,"open",decoded_path.c_str(),NULL,NULL,SW_SHOWNORMAL);
//decoded_path is "c:\pic.bmp", which is set to open in Paint by default```
I'm running under Windows 98, using Bloodshed C++.

*edit* does
----------------------
lpDirectory
[in] Pointer to a null-terminated string that specifies the default directory.
-----------------------
have anything to do with it?

2. Well, I solved it. Apparently, if an "open" fails, then the directory is opened. I had forgotten to release the file (from ofstream) before trying to open it, and so there was a sharing error. Now it works.

Popular pages Recent additions