简体   繁体   中英

MFC Open file location and select (highlight) the file

I'm using this code

STARTUPINFO si;
    PROCESS_INFORMATION pi;
    ZeroMemory(&si, sizeof(si));
    si.cb = sizeof(si);
    ZeroMemory(&pi, sizeof(pi));
    CString commandLine = _T("explorer.exe ") + CPathName(destination).DirectoryPath();
    CreateProcess(NULL, commandLine.GetBuffer(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);

to open the location of the exported file. Is there a way that the file can be selected so that I don't have to find it?

Your solution is too complex, you can just use

ShellExecute

A bunch of other solutions can be found here:

Programmatically selecting file in explorer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM