我在 C++ 中有 GetShortPathNameW 和 MSVC 2008 免费版。我只想使用它,以便它可以搜索或返回不带 .exe 扩展名的文件名。有人可以帮助我吗?代码如下:
WCHAR buffer[MAX_PATH];
LPCWSTR dataFilePath = wArgv[datafile_argv];
// Hack for Windows in case there are unicode chars in the path.
// The normal argv[] array has ????? instead of the unicode chars
// and fails, so instead we manually get the short file name, which
// is always using ANSI chars.
if (wcschr(dataFilePath, '\\') == NULL)
{
GetCurrentDirectoryW(MAX_PATH, buffer);
wcscat(buffer, L"\\");
wcscat(buffer, dataFilePath);
dataFilePath = &buffer[0];
}
if (GetShortPathNameW(dataFilePath, directoryPathBuffer, MAX_PATH) == 0)
{
platform->DisplayAlert("Unable to determine startup path: GetShortPathNameW failed.");
game_file_name = NULL;
return;
}