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();
来源:oschina
链接:https://my.oschina.net/u/4370441/blog/4358967