【问题标题】:Execute an external exe from appdata从 appdata 执行外部 exe
【发布时间】:2018-03-28 13:53:54
【问题描述】:

如何在不知道路径 c:\users\username 的用户名的情况下执行 appdata 文件夹中的 EXE 文件?

#include <stdio.h> // C library to perform Input/Output operations 
#include <tchar.h>
#include <stddef.h> // C Standard definitions 
#include <iostream> // Input/Output
#include <fstream>
#include <cstdlib>
#include <windows.h>

int main()
{
ShellExecute(NULL, "Open", "C:\\Users\\%USERNAME%\\AppData\\Roaming\\Microsoft\\mcv.exe", NULL, NULL, SW_HIDE);
}

【问题讨论】:

  • 使用ExpandEnvironmentStrings ()

标签: c++ windows shellexecute


【解决方案1】:

您可以使用 Windows 环境变量 %APPDATA%,它在 Windows 10 上解析为“C:\Users\UserName\AppData\Roaming”。

在此处了解有关 Windows 变量的更多信息:

https://www.microsoft.com/en-us/wdsi/help/folder-variables

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-15
    • 2013-08-26
    • 1970-01-01
    • 1970-01-01
    • 2021-05-12
    • 1970-01-01
    相关资源
    最近更新 更多