我为您翻译这段内容。它与IT技术有关,涉及代码编写。通过这段代码,可以正确执行并返回true,但它不会更改Path变量的值。当我在cmd中输入“setx Path“C:\Program Files\Java\jdk1.7.0_02\bin\"时,它可以工作并更改Path的值。
以下是代码:
这里会出现什么问题呢?
以下是代码:
// Prepare shellExecutInfo
SHELLEXECUTEINFO ShRun = {0};
ShRun.cbSize = sizeof(SHELLEXECUTEINFO);
ShRun.fMask = SEE_MASK_NOCLOSEPROCESS;
ShRun.hwnd = NULL;
ShRun.lpVerb =NULL;
ShRun.lpFile = "C:\\Windows\\System32\\setx.exe";
ShRun.lpParameters = "Path \"\"\"C:\\Program Files\\Java\\jdk1.7.0_02\\bin\\\"\"\"";
ShRun.lpDirectory =NULL;
ShRun.nShow = SW_SHOWNORMAL;
ShRun.hInstApp = NULL;
// Execute the file with the parameters
if(ShellExecuteEx(&ShRun))
printf("done");
else
printf("no");
这里会出现什么问题呢?
ShRun.lpParameters = "Path \"C:\\Program Files\\Java\\jdk1.7.0_02\\bin\\\"";
。 - David Heffernan