C++. FindFirstFile finds file in Debug project configuration? bu can't
find it in Release configuration
I cant figure out what causes this simple code not work in Debug config:
int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
<...>
LPCTSTR exeName = L".\\File.exe";
if (!IsFileExist(exeName))
{
   MessageBox(NULL, L"File not found", L"Setup", MB_ICONERROR | MB_OK);
   return 0;
}
<...>
}
Here is helper code:
BOOL IsFileExist(LPCWSTR lpPath)
{
    return IsDirectoryExist(lpPath);
}
BOOL IsDirectoryExist(LPCWSTR lpDir)
{
    WIN32_FIND_DATA ffd;
    HANDLE hFile = FindFirstFile(lpDir, &ffd);
    if(hFile != INVALID_HANDLE_VALUE)
    {
        FindClose(hFile);
        return TRUE;
    }
    return FALSE;
}
File named File.exe presents in both Debug and Release folders. I found
out that in case of Release configuration hFile handle equals
INVALID_HANDLE_VALUE, and that in case of Debug configuration hFile handle
contains normal file handle.
Please, can anyone tell, what I'm missing?
 
No comments:
Post a Comment