NX二次开发-打开文件夹,并同时选中指定文件
NX9+VS2012 #include <uf.h>
#include <uf_ui.h>
#include <uf_part.h>
#include <atlstr.h>
#include <iostream>
#include <sstream> UF_initialize; //获取当前part所在路径
char part_fspec[MAX_FSPEC_SIZE+];
UF_PART_ask_part_name(UF_PART_ask_display_part(), part_fspec); //转换
char new_fspec[];
sprintf(new_fspec, "/select, %s", part_fspec); //打开并选中状态
ShellExecute(NULL,"open","Explorer.exe",new_fspec,NULL,SW_SHOWDEFAULT); UF_terminate(); Caesar卢尚宇
2019年7月26日
以下
转载/原文出处https://blog.csdn.net/leehong2005/article/details/8613120#
如何用程序打开一个文件,并选中这个文件夹中指定的文件呢?其实这个功能用得很多。
1.方法一
ShellExecute(
NULL,
_T("open"),
_T("Explorer.exe"),
_T("/select, D:\\a.mp3"),
NULL,
SW_SHOWDEFAULT);
打开D盘,并选中a.mp3这个文件。
2.方法二
用 ShellExecuteEx 函数:
HELLEXECUTEINFO shex = { };
shex.cbSize = sizeof(SHELLEXECUTEINFO);
shex.lpFile = _T("explorer");
shex.lpParameters = _T(" /select, D:\\a.mp3");
shex.lpVerb = _T("open");
shex.nShow = SW_SHOWDEFAULT;
shex.lpDirectory = NULL; ShellExecuteEx(&shex);
其实上面最本质的都是用 explorer 命令。
它的命令如下:
Explorer [/e][,/root,<object>][[,/select],<sub object>]
/e
Use Explorer view (scope and results pane view). The default is
Open view (results in pane view only).
/root<object>
Specify the object in the "normal" name space that is
used as the root (top level) of this Explorer/Folder (i.e., local
path or UNC name). The default is the Desktop).
/Select
The parent folder opens and the specified object is selected.
<sub object> Specify the folder unless /select is used. The
default is the root.
Explorer /select, C:\Windows\Calc.exe
打开C:\Windows目录,并选中Calc.exe这个文件。
注意 /select后面有一个逗号,这个不要忘记了。
你可以在cmd下面,输出如下命令:
explorer /select, D:\a.mp3
这句话执行的效果跟上面方式一与方式二的效果相同。
NX二次开发-打开文件夹,并同时选中指定文件的更多相关文章
- NX二次开发-打开弹出当前part所在的文件夹
#include <uf.h> #include <uf_part.h> #include <atlstr.h> #include <iostream> ...
- C# 1.将整个文件夹复制到目标文件夹中 2.将指定文件复制到指定目标文件夹中
].Items.Clear(); string filePath = Application.StartupPath; string sourcePath = Path.Combine(filePat ...
- NX二次开发-打开part对话框UF_UI_open_part
这是UFUN帮助的官方例子 /****************************************************************************** Copyri ...
- unity 打开文件夹并鼠标选中某文件
System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "explor ...
- NX二次开发-Block UI C++界面Specify Point(指定点)控件的获取(持续补充)
Specify Point(指定点)控件的获取 NX9+VS2012 #include <uf.h> #include <uf_ui.h> UF_initialize(); / ...
- java 复制指定目录中的所有文件和文件夹到另一个指定文件夹中
package com.test; import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream ...
- [转]C#中调用资源管理器(Explorer.exe)打开指定文件夹 + 并选中指定文件 + 调用(系统默认的播放类)软件(如WMP)打开(播放歌曲等)文件
原文:http://www.crifan.com/csharp_call_explorer_to_open_destinate_folder_and_select_specific_file/ C#中 ...
- NX二次开发-UFUN将工程图转成CGM和PDF文件UF_CGM_export_cgm
文章转载自唐康林NX二次开发论坛,原文出处: http://www.nxopen.cn/thread-126-1-1.html 刚才有同学问到这个问题,如果是用NXOpen来做,直接录制一下就可以了: ...
- NX二次开发-UFUN修改当前导出CGM文件选项设置UF_CGM_set_session_export_options
文章转载自唐康林NX二次开发论坛,原文出处: http://www.nxopen.cn/thread-126-1-1.html 刚才有同学问到这个问题,如果是用NXOpen来做,直接录制一下就可以了: ...
随机推荐
- TCP协议解析及相关问题
TCP协议是什么: TCP是一种传输控制层的协议(TCP,Transmission Control Protocol)是为了在不可靠的互联网络上提供可靠的端到端字节流而专门设计的一个传输协议.也就是要 ...
- JavaSE---枚举
1.概述 1.1 某些情况下,一个类的对象是 有限且固定的,eg:四季... 1.2 手动实现枚举类: 1.1.1 私有化构造器 1.1.2 将类的属性用private final修饰: 将类的实例 ...
- Java中的LinkedList
- Linux系统上安装MySQL 5.5prm
http://www.cnblogs.com/sunson/articles/2172086.html
- luoguP2148 [SDOI2009]E&D [sg函数][组合游戏]
题目描述 小E 与小W 进行一项名为“E&D”游戏. 游戏的规则如下: 桌子上有2n 堆石子,编号为1..2n.其中,为了方便起见,我们将第2k-1 堆与第2k 堆 (1 ≤ k ≤ n)视为 ...
- EXCEL2016 OLE/COM开发-常用功能封装代码
hpp #pragma once #include "stdafx.h" #include "CApplication.h" #include "CW ...
- HIve分组查询返回每组的一条记录
select a.lng,a.lat from (select row_number() over ( partition by uid,grid_id) as rnum,weighted_centr ...
- MakeDown渲染出错
MakeDown渲染出错 makedown作为程序员不可或缺的编辑工具,平时的使用技巧也是非常多的. 今天给新电脑装了一个,发现出现了错误(win10环境下),如图: 错误的表现形式即:不能实时预览M ...
- Invoking destroy method 'close' on bean with name 'dataSource'
Invoking destroy method 'close' on bean with name 'dataSource' Spring与Mybatis整合时出现的问题,找了一晚上结果是一个属性写错 ...
- Xen的半虚拟化(Paravirtualization)
三个特权级 IA-32体系提供了4个特权级别,正常情况下只用了2个, 操作系统运行在Ring 0,而应用程序运行在Ring 3. Xen让自己运行在Ring 0, 而操作系统运行在Ring 1, 应用 ...