un poco más posibilidades aquí:
Si desea abrir - por ejemplo - el archivo por defecto con Notepad ++ (si está instalado), puede escanear por su clave de registro si existe y dónde se encuentra, (Generalmente HKLM\SOFTWARE\Wow6432Node\Notepad++
[probado Win7]) luego toma ese camino y ábrelo.
std::wstring file = L"C:\\Outfile.txt";
if (NotepadPlusPlusExists()) //Open with Notepad++ or use an other program... (maybe your own ?)
{
std::wstring wsNPPPath = GetNotepadPlusPlusPath();
ShellExecuteW(HWND, L"open", wsNPPPath.c_str(), file.c_str(), NULL, SW_NORMAL);
}
else //Open with default associated program <---
ShellExecuteW(HWND, NULL, file.c_str(), NULL, NULL, SW_NORMAL);
Si desea que el usuario sea capaz de cambiar el programa predeterminado o seleccionar un programa que él/ella quiere usar, se puede abrir la opción "Abrir con" de diálogo.
//std::wstring StringArgsW(const wchar_t *format, ...);
std::wstring wsCmdOpenWith = StringArgsW(L"C:\\Windows\\system32\\shell32.dll,OpenAs_RunDLL \"%s\"", file.c_str());
ShellExecuteW(HWND, L"open", L"C:\\Windows\\system32\\rundll32.exe", wsCmdOpenWith.c_str(), NULL, SW_NORMAL);
También puede abrir el archivo en el explorador.
std::wstring wsCmdExplorer = StringArgsW(L"/select,\"%s\"", file.c_str());
ShellExecuteW(HWND, L"open", L"explorer.exe", wsCmdExplorer.c_str(), NULL, SW_NORMAL);
Si ya lo hizo funcionar, ¿cuál es la pregunta? –