c++windowshwndshell-extensionsshell-namespace-extension

how to display the virtual folder only when user open the windows explorer from an app on win 7?


--------------------------------second updates------------------------

I tried:

STDAPI_(BOOL) DllMain(HINSTANCE hInstance, DWORD dwReason, void *)
{
// Get the path and module name.
WCHAR szModulePathAndName[MAX_PATH];
GetModuleFileName(hInstance, szModulePathAndName, ARRAYSIZE(szModulePathAndName));

std::ofstream outfile("DllMain.txt");
outfile << szModulePathAndName << std::endl;
outfile.close();

if (dwReason == DLL_PROCESS_ATTACH)
{
    g_hInst = hInstance;
    DisableThreadLibraryCalls(hInstance);
}
return TRUE;
}

This doesn't work. The content to be print in the txt file is: 00000000000CDEE0 And it only print once when I register the dll. After that, no matter how many times I browse the virtual folder , open it, it never eneter DllMain to print the string again.


I am using Microsoft windows 7.0 SDK sample ( ExplorerDataProvider ) to create a virtual folder on "My Computer", like following: enter image description here

When I open the file browser dialog, it displays this virtual folder. When I click "Save as" from Microfost office, the windows file explorer dialog pops up and still display this virtual folder. I wrote a C++ application, which can also save the file when clicks "export". It will open the windows file explorer dialog and when the user selects the directory and click save, it can save the file. My problem is: I hope the virtual folder can be only displayed when I use my C++ program to open the file dialog. If I open the windows explorer outside my application, the virtual folder is invisible. How could I do that? It seems that once I register the dll for the virtual folder, the virtual folder is always there. One possible solution for me is to register the virtual folder dll when my application is opening windows file explorer and then unregister it when the user closes it in the application, but the user can still see it if the user opening the windows explorer outside of the application when the windows file explorer is showing up in the application.

I didn't find anything like SetVisible function in IShellFolder.


Solution

  • You can return false in DLLMain if the file name returned by GetModuleFileName(NULL) is anything other than your C++ program.