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;
}

相关资料:

相关推荐
i小杨12 分钟前
python 项目相关
开发语言·python
zh_xuan12 分钟前
kotlin定义函数和变量
android·开发语言·kotlin
CoderCodingNo13 分钟前
【GESP】C++五级真题(贪心思想考点) luogu-P11960 [GESP202503 五级] 平均分配
开发语言·c++·算法
weixin_4624462324 分钟前
使用 Tornado + systemd 搭建图片静态服务(imgserver)
开发语言·python·tornado
源码获取_wx:Fegn089525 分钟前
基于springboot + vue小区人脸识别门禁系统
java·开发语言·vue.js·spring boot·后端·spring
Herbert_hwt25 分钟前
C语言赋值操作符详解:从基础使用到避坑指南
c语言
别多香了30 分钟前
python基础之面向对象&异常捕获
开发语言·python
春蕾夏荷_72829772531 分钟前
Qt 命令行工具
开发语言·qt
寂寞旅行1 小时前
java敏感词过滤(sensitive-word)
java·开发语言·word
90后小陈老师1 小时前
Java项目接入AI大模型的四种方式
java·开发语言·人工智能