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

相关资料:

相关推荐
郑州光合科技余经理5 小时前
代码展示:PHP搭建海外版外卖系统源码解析
java·开发语言·前端·后端·系统架构·uni-app·php
feifeigo1235 小时前
matlab画图工具
开发语言·matlab
dustcell.5 小时前
haproxy七层代理
java·开发语言·前端
norlan_jame5 小时前
C-PHY与D-PHY差异
c语言·开发语言
多恩Stone6 小时前
【C++入门扫盲1】C++ 与 Python:类型、编译器/解释器与 CPU 的关系
开发语言·c++·人工智能·python·算法·3d·aigc
QQ4022054966 小时前
Python+django+vue3预制菜半成品配菜平台
开发语言·python·django
czy87874756 小时前
除了结构体之外,C语言中还有哪些其他方式可以模拟C++的面向对象编程特性
c语言
遥遥江上月6 小时前
Node.js + Stagehand + Python 部署
开发语言·python·node.js
m0_531237176 小时前
C语言-数组练习进阶
c语言·开发语言·算法
Railshiqian7 小时前
给android源码下的模拟器添加两个后排屏的修改
android·开发语言·javascript