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

相关资料:

相关推荐
wjs20241 天前
XPath 运算符
开发语言
Mr.朱鹏1 天前
大模型入门学习路径(Java开发者版)上
java·开发语言·spring boot·spring·大模型·llm·transformer
黎雁·泠崖1 天前
C 语言指针进阶教程:const 修饰、野指针规避与传址调用
c语言·开发语言
lsx2024061 天前
ASP TextStream
开发语言
cike_y1 天前
JSP标签&JSTL标签&EL表达式
java·开发语言·jsp
秃然想通1 天前
Java继承详解:从零开始理解“父子关系”编程
java·开发语言
嘻嘻嘻开心1 天前
List集合接口
java·开发语言·list
源码获取_wx:Fegn08951 天前
基于springboot + vue物业管理系统
java·开发语言·vue.js·spring boot·后端·spring·课程设计
cike_y1 天前
JavaWeb-JDBC&事务回滚
java·开发语言·javaweb
青啊青斯1 天前
python markdown转word【包括字体指定】
开发语言·python·word