0
我在JavaScript中有一个项目,它需要与节点一起运行并输出到一个文件,所以我决定使用C++,我需要使用System命令。C++获取系统文件的路径
我使用Visual Studio BTW
我需要在.exe文件链接到另一个文件路径,这样的系统命令可以使用它。例如:如果我有一个包含Generator/main.js的exe文件,我如何获得它的路径,以便exe文件是可移植的。我如何返回包含文件的路径?这可能吗?
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
cout << "Generator!";
cin.get();
// This needs to be run from CMD, how do I link to Generator in the project folder?
system("node Generator/main.js > %userprofile%/Desktop/Gen.txt");
return 0;
}
编辑如何从一个exe文件复制到一个文件,如桌面?
为什么你认为你需要C++?为什么不直接执行Node.JS呢? –
嵌入到应用程序中的资源显然没有“路径”。你需要研究你正在使用的资源框架。然后使用管道。可能与'system'无关,只是WinAPI函数。 –