How can you open a file with the program associated with its file extension?

前端 未结 6 1517
半阙折子戏
半阙折子戏 2020-12-24 13:50

Is there a simple way to open a file by its associated program in windows? (like double clicking it in windows explorer but done automatically with my code)

For exam

6条回答
  •  一生所求
    2020-12-24 14:09

    See Launching Applications:

    ShellExecute(NULL, "open", L"c:\\outfile.txt", NULL, NULL, SW_SHOW);
    

    On windows, a good memory hook is to think of all data-files being executable by the shell. You can also try it out in a command box, where you can just type a filename, and it will be opened up. Or, the other way around, every file in Windows can be opened, and the default opening-action for executable files is to execute them.

提交回复
热议问题