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

相关资料:

相关推荐
暗影八度16 小时前
OpenMetadata Python ingestion 开发环境搭建与运行文档
开发语言·python
basketball61616 小时前
C++ iomanip 常用函数
开发语言·c++
清水白石00816 小时前
从“能装上”到“可复现”:Python 团队如何正确使用 requirements.txt、锁定文件与依赖分组
开发语言·人工智能·python
赏金术士16 小时前
Kotlin 习题集 · 基础篇
android·开发语言·kotlin
jiayong2316 小时前
Python面试题集 - 基础语法与核心概念
开发语言·windows·python
ch.ju17 小时前
Java程序设计(第3版)第三章——数组的遍历
java·开发语言
凯瑟琳.奥古斯特17 小时前
Django Flask FastAPI 三者对比
开发语言·python·django·flask·fastapi
青春易逝丶17 小时前
JAVA基础面试题
java·开发语言
Austindatabases17 小时前
数据不准确,数据丢失,SQLite怎么保证计算不丢数--SQLite 五脏俱全系列 (5)
java·开发语言·数据库·sqlite
滑稽之神眷顾者17 小时前
基于正倒排索引的文档搜索引擎测试报告
java·开发语言·功能测试