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二次开发-打开文件夹,并同时选中指定文件的更多相关文章

  1. NX二次开发-打开弹出当前part所在的文件夹

    #include <uf.h> #include <uf_part.h> #include <atlstr.h> #include <iostream> ...

  2. C# 1.将整个文件夹复制到目标文件夹中 2.将指定文件复制到指定目标文件夹中

    ].Items.Clear(); string filePath = Application.StartupPath; string sourcePath = Path.Combine(filePat ...

  3. NX二次开发-打开part对话框UF_UI_open_part

    这是UFUN帮助的官方例子 /****************************************************************************** Copyri ...

  4. unity 打开文件夹并鼠标选中某文件

    System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "explor ...

  5. NX二次开发-Block UI C++界面Specify Point(指定点)控件的获取(持续补充)

    Specify Point(指定点)控件的获取 NX9+VS2012 #include <uf.h> #include <uf_ui.h> UF_initialize(); / ...

  6. java 复制指定目录中的所有文件和文件夹到另一个指定文件夹中

    package com.test; import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream ...

  7. [转]C#中调用资源管理器(Explorer.exe)打开指定文件夹 + 并选中指定文件 + 调用(系统默认的播放类)软件(如WMP)打开(播放歌曲等)文件

    原文:http://www.crifan.com/csharp_call_explorer_to_open_destinate_folder_and_select_specific_file/ C#中 ...

  8. NX二次开发-UFUN将工程图转成CGM和PDF文件UF_CGM_export_cgm

    文章转载自唐康林NX二次开发论坛,原文出处: http://www.nxopen.cn/thread-126-1-1.html 刚才有同学问到这个问题,如果是用NXOpen来做,直接录制一下就可以了: ...

  9. NX二次开发-UFUN修改当前导出CGM文件选项设置UF_CGM_set_session_export_options

    文章转载自唐康林NX二次开发论坛,原文出处: http://www.nxopen.cn/thread-126-1-1.html 刚才有同学问到这个问题,如果是用NXOpen来做,直接录制一下就可以了: ...

随机推荐

  1. [人物存档]【AI少女】【捏脸数据】朴素风格

    点击下载(城通网盘):AISChaF_20191115113752642.png 点击下载(城通网盘):AISChaF_20191111232359711.png

  2. php上传文件(简易版)

    1.前台form表单处添加 enctype="multipart/form-data" 2. //上传文件保存到目录 header("content-type:text/ ...

  3. Delphi实现获取句柄并发送消息的方法(FindWindow、FindWindowEx、EnumChildWindows、SendMessage)

    Delphi实现获取句柄并发送消息的方法 本文以实例形式详细说明了Delphi获取句柄并发送消息的方法,具体用法说明如下: 查找另外一个窗口的句柄: handle := FindWindow(nil, ...

  4. px4_impl_posix_cmake学习

    ############################################################################ # # Copyright (c) PX4 D ...

  5. luoguP3690 【模板】Link Cut Tree (动态树)[LCT]

    题目背景 动态树 题目描述 给定N个点以及每个点的权值,要你处理接下来的M个操作.操作有4种.操作从0到3编号.点从1到N编号. 0:后接两个整数(x,y),代表询问从x到y的路径上的点的权值的xor ...

  6. Ext——xtype各组件类型

    Ext.form.TextField的 xtype类型

  7. 解决spring boot中普通类中使用service为null 的方法

    我使用的是springboot+mybatisplus +mysql1.创建一个SpringUtil工具类 import org.springframework.beans.BeansExceptio ...

  8. Awesome Adb——一份超全超详细的 ADB 用法大全

    https://github.com/mzlogin/awesome-adb https://www.cnblogs.com/bravesnail/articles/5850335.html     ...

  9. 20. Jmeter抓包之APP请求

    APP测试过程中我们经常需要抓包,通常我们使用fiddler或者Charles.但是jmeter也可以抓包,而且非常好用,闲话不多说,下面进入正题. 步骤: 1.选择测试计划,添加线程组 2.选择工作 ...

  10. JAVA StringUtils 坑汇总

    1 StringUtils.split() VS String.split(); public static void main(String args[]){            String r ...