我调用GetModuleFileName
函数,以检索指定模块的完全限定路径,以便通过Process::Start
方法调用同一文件中的另一个 .exe。
但是,当路径包含非拉丁字符(在我的情况下为希腊字符)时,无法调用 .exe。
有什么办法可以解决这个问题吗?
代码:
TCHAR path[1000];
GetModuleFileName(NULL, path, 1000) ; // Retrieves the fully qualified path for the file that
// contains the specified module.
PathRemoveFileSpec(path); // Removes the trailing file name and backslash from a path (TCHAR).
CHAR mypath[1000];
// Convert TCHAR to CHAR.
wcstombs(mypath, path, wcslen(path) + 1);
// Formatting the string: constructing a string by substituting computed values at various
// places in a constant string.
CHAR mypath2[1000];
sprintf_s(mypath2, "%s\\Client_JoypadCodesApplication.exe", mypath);
String^ result;
result = marshal_as<String^>(mypath2);
Process::Start(result);