c++ - 为什么命令不执行?
问题描述
我尝试对 CMD 执行命令,但它不起作用包括:
#include <Windows.h>
#include <processthreadsapi.h>
#include <shellapi.h>
#include <stdio.h>
#include <iostream>
我如何尝试打开记事本:
ShellExecute(NULL, (LPCWSTR)"open", (LPCWSTR)"cmd", (LPCWSTR)"/c notepad.exe", NULL, SW_NORMAL);
解决方案
这有效
ShellExecute(NULL, L"open", L"cmd", L"/c notepad.exe", NULL, SW_NORMAL);
不要使用强制转换来消除编译器错误。错误告诉您您使用了错误的类型,请改用正确的类型。
推荐阅读
- sql - 检查 wp_posts 或 wp_postmeta 表中的更新
- python - 为什么 bs4 错误地解释网站架构上的 JSON?
- python - 为什么 flake8 对我在“as”块中定义的东西说“未定义的名称”?
- fabricjs - 多边形动态操作后的边界/选择框的fabricjs问题
- php - 在 mysql 8 中转换日期格式 [ string d/m/y TO date ]
- flutter - Flutter 金色图像测试差异阈值
- c# - 如果请求对象包含一个没有相应模型属性的属性会发生什么?
- ssl - 使用 openssl 验证信任链的问题
- python - 在 plotly express 图中可视化多行
- node.js - Sequelize 和 WHERE 1=1 中的函数