The bug is not in foobar2000. foobar uses SHOpenFolderAndSelectItems function for the "Open containing folder" feature and the OS seems to suffer from misbehavior with it.
I made a small test program that shows the same issue:
#include <windows.h>
#include <Shlobj.h>
#include <Objbase.h>
#include <stdio.h>
#include <tchar.h>
#pragma comment(lib, "ole32")
#pragma comment(lib, "shell32")
int main(int argc, char *argv)
{
HRESULT res;
ITEMIDLIST *pIDL;
res = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (res != S_OK) printf("CoInitializeEx returned 0x%08x\n", res);
pIDL = ILCreateFromPath(_T("C:\\Windows\\explorer.exe"));
if (pIDL != NULL) {
res = SHOpenFolderAndSelectItems(pIDL, 0, NULL, 0);
if (res != S_OK) printf("SHOpenFolderAndSelectItems returned with value 0x%08x\n", res);
ILFree(pIDL);
} else {
printf("ILCreateFromPath failed\n");
}
return 0;
}