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:
If
ShellExecuteA()
returns an error (not sure it does), if it does I could brute-force it; is it.mpeg
? Is it.avi
? Is it.h264
? etc...Do a search in the known location with the filename missing the extension, and then grab the full filename with whatever it finds (all file names are unique, even excluding the extension).
I know I could add the extension in the .mp3
tag, but there are reasons why I'd rather not do that.
CodePudding user response:
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.
CodePudding user response:
FindFirstA got me the results I wanted obviously there are more direct ways than sstream but other stuff is going on that isn't important to the actual problem
std::stringstream sstrm1, sstrm2;
sstrm1 << "C:\\Users\\user\\Desktop\\";
sstrm2 << sstrm1.str() << "Notes.*";
HANDLE hFind;
WIN32_FIND_DATAA data;
hFind = FindFirstFileA(sstrm2.str().c_str(), &data);
sstrm1 << data.cFileName;
ShellExecuteA(NULL, "open", sstrm1.str().c_str(), NULL, NULL, SW_SHOWNORMAL);