C++/WinAPIでビルドされた実行可能ファイルは、同じフォルダーに配置されたファイルをチェックし、PathFileExists
そのために使用します。通常のコンピューターで実行するとファイルが見つかりますが、RemoteAppで実行可能ファイルを公開し、 Web アクセスから実行すると、ファイルが見つかりません。私は何が欠けているでしょうか?
// This is the file I want to find (located in the same directory as the EXE)
wstring myfile = L"myfile.conf";
BOOL abspath = FALSE;
// Trying to get the absolute path first
DWORD nBufferLength = MAX_PATH;
wchar_t szCurrentDirectory[MAX_PATH + 1];
if (GetCurrentDirectory(nBufferLength, szCurrentDirectory) == 0) {
szCurrentDirectory[MAX_PATH + 1] = '\0';
} else {
abspath = true;
}
if (abspath) {
// Create the absolute path to the file
myfile = L'\\' + myfile;
myfile = szCurrentDirectory + myfile ;
MessageBox(hWnd, ConvertToUNC(myfile).c_str(), L"Absolute Path", MB_ICONINFORMATION);
} else {
// Get the UNC path
myfile = ConvertToUNC(myfile);
MessageBox(hWnd, myfile.c_str(), L"UNC Path", MB_ICONINFORMATION);
}
// Try to find file
int retval = PathFileExists(myfile.c_str());
if (retval == 1) {
// Do something
} else {
// File not found
}
ConvertToUNC
関数は here からコピーされます。私が見ているのは、実行可能ファイルは別の場所にありますが、絶対パスはC:\Windows
. 何が原因なのか本当にわかりません。サーバーは Windows 2012 R2 で、前述したように、アプリケーションは RemoteApp Web Access を介して実行されます。返される UNC パスは、ファイルの名前だけです (ボリュームやフォルダーは含まれません)。