当前位置:网站首页>C#使用WinExec调用exe程序
C#使用WinExec调用exe程序
2022-06-29 09:26:00 【zlbcdn】
实现
1、添加引用
using System.Runtime.InteropServices;//调用外部的DLL2、定义win32API
//调用exe
[DllImport("kernel32.dll")]
public static extern int WinExec(string exeName, int operType);
//生成执行数据
private void generateExecuteData_ItemClick(object sender, ItemClickEventArgs e)
{
WinExec(@"C:\ExecuteRecords\OrdersExecutionRecords.exe", 5);
}WinExec说明
1、方法的返回值。
方法成功,返回>31的整数值;
方法失败,返回:
| 返回结果 | 说明 |
|---|---|
| 0 | 系统内存或资源不够 |
| ERROR_BAD_FORMAT | 非法的exe程序 |
| ERROR_FILE_NOT_FOUND | 文件未找到 |
| ERROR_PATH_NOT_FOUND | 路径未找到 |
2、参数
方法有两个参数:第一个参数lpCmdLine为路径+程序、第二个参数nCmdShow为展示方式。
2.1lpCmdLine
搜索顺序:
1、参数指定路径
2、应用所在路径
3、当前路径
4、system路径(可调用GetSystemDirectory方法查询)
5、window路径(可调用GetWindowsDirectory方法查询)
6、环境变量中path路径
2.2uCmdShow
具体说明如下
| 参数 | 说明 |
|---|---|
| 11 | 最小化窗体 |
| 0 | 窗体隐藏 |
| 3 | 最大化窗体 |
| 6 | 最小化窗体后,激活Z轴上的上一层窗体 |
| 9 | 重新初始化窗体 |
| 5 | 展示窗体 |
| 10 | |
| 3 | 激活窗体,并最大化 |
| 2 | 激活窗体,并最小化 |
| 7 | 展示窗体,并设为最小化 |
| 8 | 展示窗体的大小及位置为当前大小及位置 |
| 4 | 展示窗体的大小及位置为最常用大小及位置 |
| 1 | 激活并展示一个窗体。不管窗体为最小化或最大化状态,系统将其恢复至原始大小及位置。当初次使用时,建议使用本值 |
边栏推荐
- L2-031 go deep into the tiger's den (25 points)
- Codeforces Round #641 Div2
- Slide the custom control to close the activity control
- DevExpress的双击获取单元格数据
- Codeforces Round #641 Div2
- Power Strings【KMP循环节】
- JVM instructions for four call methods
- 完全二叉树的权值 递归做法 ——最后的编程挑战
- Talk about threads and concurrency
- 这个开源项目超哇塞,手写照片在线生成
猜你喜欢
随机推荐
蛇形填数
CodeForces - 1151B 思维
520 diamond Championship 2021
TLAB of JVM
Codeforces Round #659 (Div. 2)
2019.11.3学习总结
If I were in Beijing, where would it be better to open an account? In addition, is it safe to open an account online now?
2019.10.6训练总结
MySQL innodb每行数据长度的限制
GridView of basic component of shutter
2019.10.23训练总结
【51nod 1215】数组的宽度
nacos注册中心集群
PGP在加密技术中的应用
Related problems of pointer array, array pointer and parameter passing
走迷宫 bfs 中等+——最后的编程挑战
Time varying and non time varying
manacher
Wandering -- the last programming challenge
JVM method return address









