ShellExecute打開文件打開文件夾的用法


 1 #include <uf.h>
 2 #include <uf_part.h>  3 #include <atlstr.h>  4 #include <iostream>  5 #include <sstream>  6  7 using std::string;  8  9 10  UF_initialize(); 11 12 //獲取當前part的tag 13 tag_t WorkPart = UF_PART_ask_display_part(); 14 15 //獲取當前part所在路徑 16 char part_fspec[MAX_FSPEC_BUFSIZE+1]; 17  UF_PART_ask_part_name(WorkPart, part_fspec); 18 19 //反向找位置,分割字符串(只取文件夾路徑) 20 string strPath = part_fspec; 21 string strDir; 22 int nPos = strPath.find_last_of('\\'); 23 if (string::npos != nPos) 24  { 25 strDir = strPath.substr(0, nPos); 26  } 27 28 //方法1 29 //轉換 30 //char msg[256]; 31 //sprintf_s(msg, "start %s", strDir.c_str()); 32 33 //打開並顯示文件夾(windows cmd) 34 //system(msg); 35 36 //方法2 37 //ShellExecute打開一個文件 38 //ShellExecute(NULL, "open", "C:\\11.txt", NULL, NULL, SW_SHOWNORMAL); 39 40 ////ShellExecute打開並顯示文件夾 41 ShellExecute(NULL, "open", strDir.c_str(), NULL, NULL, SW_SHOWNORMAL); 42 43 UF_terminate();


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM