Programmatically selecting file in explorer

后端 未结 3 1527
天涯浪人
天涯浪人 2020-12-05 03:12

In my application I can programmatically open explorer and select a file using the following code:

void BrowseToFile(LPCTSTR filename)
{
    CString strArgs;         


        
3条回答
  •  生来不讨喜
    2020-12-05 03:50

    Try the '/n' option. This will, however, open a new folder - perhaps already opened. But, at least, the file you specify is selected.

    /n,/select,
    

    SHOpenFolderAndSelectItems always fails in my case and I can't figure out why. Btw, you must call CoInitialize/CoInitializeEx before calling this one.

提交回复
热议问题