2 years ago
#51816
Unhandled Exception
Compiler Error C2664 - after changing from Debug to Release rebuild
Disclaimer : Started this a few months back and now revisiting. Still not working much with Visual Studio and Windows API.
The code works when built as Debug X86.
The issue is when I switch from Debug to Release and rebuild the following errors appear.
The lines of code causing the issue are :
_tprintf("Invalid Handle %s <DIR>\n", szDir);
and
_tprintf("Error\n");
I tried changing the project from characterset to None, Unicode, MultiByte characters but they all generated the same errors.
Any idea why simply changing from Debug to Release causes this issue and how to resolve? This is something I would have expected when changing from X86 to X64.
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <strsafe.h>
#pragma comment(lib, "User32.lib")
int _tmain(int argc, TCHAR* argv[])
{
WIN32_FIND_DATA ffd;
LARGE_INTEGER filesize;
TCHAR szDir[MAX_PATH];
size_t length_of_arg;
HANDLE hFind = INVALID_HANDLE_VALUE;
DWORD dwError = 0;
if (argc != 2)
{
_tprintf(TEXT("\nUsage: %s <directory name>\n"), argv[0]);
return (-1);
}
StringCchLength(argv[1], MAX_PATH, &length_of_arg);
if (length_of_arg > (MAX_PATH - 3))
{
_tprintf(TEXT("\nDirectory path is too long.\n"));
return (-1);
}
_tprintf(TEXT("\nTarget directory is %s\n\n"), argv[1]);
StringCchCopy(szDir, MAX_PATH, argv[1]);
StringCchCat(szDir, MAX_PATH, TEXT("\\*"));
hFind = FindFirstFile(szDir, &ffd);
if (INVALID_HANDLE_VALUE == hFind)
{
_tprintf("Invalid Handle %s <DIR>\n", szDir);
return dwError;
}
:
///Doing other stuff here....
:
dwError = GetLastError();
if (dwError != ERROR_NO_MORE_FILES)
{
//DisplayErrorBox(TEXT("FindFirstFile"));
_tprintf("Error\n");
}
FindClose(hFind);
return dwError;
}
windows
visual-studio
release
0 Answers
Your Answer