c++shellexecute

ShellExecuteA but I don't know the extension


std::string str1 = "C:\\Users\\user\\Desktop\\Notes";
ShellExecuteA(NULL, "open", str1.c_str(), NULL, NULL, SW_SHOWNORMAL);

The code isn't worth much.

I have an .mp3 in a DJ program. In one of the tags, it holds the filename of the associated video. All the videos are .mpeg.

With the DJ software's API, I can grab the tag. I know where the video files are (all in one folder). I can open the video with ShellExecuteA(), because whilst the tag might not contain the full filename+extension, I know the extension.

Now the problem - I want to start using .avi or .h254 or whatever. I don't know the extension anymore, and ShellExecuteA() needs an extension.

What can I do?

My guesses are:

I know I could add the extension in the .mp3 tag, but there are reasons why I'd rather not do that.


Solution

  • ShellExecute does not need extension. It needs the exact file name. If extensions are hidden in Windows Explorer - make them visible. If you don't know the extension for other reason, use FindFirst with wildcard * (Notes*) to find the full name.