C语言隐藏执行其他程序

WinExec函数

c 复制代码
#include<windows.h>
int main()
{
	WinExec("notepad.exe", SW_HIDE);
	return 0;
}
  • SW_HIDE 隐藏
  • SW_SHOW 显示

ShellExecute函数

在C语言中使用ShellExecute函数可以执行外部程序,比如打开一个文件、运行一个程序等。

c 复制代码
#include <windows.h>
#include <stdio.h>

int main() {
    // 记事本程序路径
    const char* notepadPath = "notepad.exe";

    // 调用ShellExecute函数打开记事本
    HINSTANCE result = ShellExecute(NULL, "open", notepadPath, NULL, NULL, SW_HIDE);

    // 检查执行结果
   if ((INT_PTR)result <= 32) {
        printf("Failed to open Notepad!\n");
        return 1;
    } else {
        printf("Notepad opened successfully!\n");
    }

    return 0;
}

相关资料:

相关推荐
froginwe118 分钟前
传输对象模式(Object Transfer Pattern)
开发语言
qq_4061761417 分钟前
深入理解 JavaScript 闭包:从原理到实战避坑
开发语言·前端·javascript
float_六七22 分钟前
JavaScript变量声明:var的奥秘
开发语言·前端·javascript
1candobetter23 分钟前
JAVA后端开发——深入理解 Java Static
java·开发语言
FuckPatience30 分钟前
C# SqlSugar+SQLite: 无法加载 DLL“e_sqlite3”: 找不到指定的模块
开发语言·c#
清水白石00831 分钟前
深入理解 Python 字典的有序性:从 3.6 的“意外之喜”到 3.7 的官方承诺
开发语言·python
写代码的【黑咖啡】1 小时前
Python 中的 Requests 库:轻松进行 HTTP 请求
开发语言·python·http
BD_Marathon1 小时前
MyBatis各种查询功能
java·开发语言·mybatis
研☆香1 小时前
JavaScript 特点介绍
开发语言·javascript·ecmascript
Howrun7771 小时前
虚幻引擎_AController_APlayerController_AAIController
开发语言·c++·游戏引擎·虚幻