首页 > 解决方案 > 为什么命令不执行?

问题描述

我尝试对 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);

标签: c++

解决方案


这有效

ShellExecute(NULL, L"open", L"cmd", L"/c notepad.exe", NULL, SW_NORMAL);

不要使用强制转换来消除编译器错误。错误告诉您您使用了错误的类型,请改用正确的类型。


推荐阅读