How to perform opening a file?
-
Given the path of the file, how to open it with code? just like you double click it. Thank you very much!!!
Use
ShellExecute
with the "open" verb. e.g.ShellExecute( NULL, // HWND hwnd _T("open"), // LPCTSTR lpOperation _T("C:\\a.txt"), // LPCTSTR lpFile NULL, // LPCTSTR lpParameters NULL, // LPCTSTR lpDirectory SW_SHOWDEFAULT // INT nShowCmd );
You will need to#include <shellapi.h>
and link to "shell32.lib". Steve -
Use
ShellExecute
with the "open" verb. e.g.ShellExecute( NULL, // HWND hwnd _T("open"), // LPCTSTR lpOperation _T("C:\\a.txt"), // LPCTSTR lpFile NULL, // LPCTSTR lpParameters NULL, // LPCTSTR lpDirectory SW_SHOWDEFAULT // INT nShowCmd );
You will need to#include <shellapi.h>
and link to "shell32.lib". Steve -
Given the path of the file, how to open it with code? just like you double click it. Thank you very much!!!