我想知道如何在C ++中打开一个文件(比如双击它)?
Provided you have the ".txt" extension registered (and text files should be associated with Notepad in a default installation, or something else if you've changed it from Explorer - you'd have to work pretty hard to disassociate them), Windows will open it for you without you having to specify the executable name:
ShellExecute (hwnd,"open","c:\\x.txt",NULL,NULL,SW_SHOW);
or, for a web page in your browser of choice:
ShellExecute (hwnd,"open","http://www.microsoft.com",NULL,NULL,SW_SHOW);
使用ShellExecute函数和“打开”操作。
Use ShellExecute with the "open" verb. See this article for more information.
简单方法:system(“notepad.exe [location to file]”);
You mean like open explorer?
How about using
system("explorer.exe file.to.open");
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.