当前位置:网站首页>C # use winexec to call exe program
C # use winexec to call exe program
2022-06-29 10:26:00 【zlbcdn】
Realization
1、 Add reference
using System.Runtime.InteropServices;// Call external DLL2、 Definition win32API
// call exe
[DllImport("kernel32.dll")]
public static extern int WinExec(string exeName, int operType);
// Generate execution data
private void generateExecuteData_ItemClick(object sender, ItemClickEventArgs e)
{
WinExec(@"C:\ExecuteRecords\OrdersExecutionRecords.exe", 5);
}WinExec explain
1、 Return value of method .
Method success , return >31 The integer value ;
Method failed , return :
| Return results | explain |
|---|---|
| 0 | Insufficient system memory or resources |
| ERROR_BAD_FORMAT | Illegal exe Program |
| ERROR_FILE_NOT_FOUND | File not found |
| ERROR_PATH_NOT_FOUND | path not found |
2、 Parameters
Method has two parameters : The first parameter lpCmdLine Is the path + Program 、 The second parameter nCmdShow For presentation .
2.1lpCmdLine
Search order :
1、 Parameter to specify the path
2、 Application path
3、 current path
4、system route ( Callable GetSystemDirectory Method query )
5、window route ( Callable GetWindowsDirectory Method query )
6、 In the environment variables path route
2.2uCmdShow
The details are as follows
| Parameters | explain |
|---|---|
| 11 | Minimize forms |
| 0 | The form is hidden |
| 3 | Maximize form |
| 6 | After minimizing the form , Activate Z The upper window on the axis |
| 9 | Reinitialize the form |
| 5 | Show form |
| 10 | |
| 3 | Activate forms , And maximize it |
| 2 | Activate forms , And minimize |
| 7 | Show form , And set to minimize |
| 8 | The size and position of the display form is the current size and position |
| 4 | The size and position of the display form is the most commonly used size and position |
| 1 | Activate and display a form . Whether the form is minimized or maximized , The system restores it to its original size and location . When first used , This value is recommended |
边栏推荐
猜你喜欢
随机推荐
HDU 6778 car (group enumeration -- > shape pressure DP)
Power strings [KMP cycle section]
逆向思维-小故事
Application of Pgp in encryption technology
信号作品:时变和时不变
Signal works: time varying and time invariant
Arc view and arc viewpager
EDA与VHDL题库
L2-031 深入虎穴 (25 分)
Beautiful ruins around Kiev -- a safe guide to Chernobyl!
JNI. H description
SeaweedFS安全配置(Security Configuration)
We can't tell the difference between distributed and cluster. Let's tell the story of two cooks cooking
DevExpress的双击获取单元格数据
Shanke's C language 2018 exercise (Telecom)
2019.10.16训练总结
L1-009 N个数求和 (20 分)
1098 insertion or heap sort (25 points)
MySQL中update一条record的过程
Serpentine filling number








