开发者

Weird Debugger Behavior

开发者 https://www.devze.com 2023-01-14 23:29 出处:网络
The following code snippet behaves in Debug mode (VC++ 2005) differently than in Release: HANDLE hFileRead;

The following code snippet behaves in Debug mode (VC++ 2005) differently than in Release:

HANDLE hFileRead;
hFileRead = CreateFile(pszListFile,           //    lpFileName,
                       GENERIC_READ,          //    dwDesiredAccess,
                       FILE_SHARE_READ,       //    dwShareMode,
                       NULL,                  //    lpSecurityAttributes,
                       OPEN_EXISTING,         //    dwCreationDisposition,
                       FILE_ATTRIBUTE_NORMAL, //    dwFlagsAndAttributes,
                       0);                    //    hTemplateFile

In Release mode it works perfectly. In Debug mode, it it returns INVALID_HANDLE_VALUE in hFileRead. Further retrieving GetLastError() reveals system error 3:

ERR开发者_StackOverflowOR_PATH_NOT_FOUND ("The system cannot find the path specified.")

This is weird. In Release mode it can find it but in Debug mode it cannot find it? How is this possible?

Any ideas?


The difference can in in the current directory, if pszListFile contains relative path.


The problem did not occur again. Abandoned until further notice.

0

精彩评论

暂无评论...
验证码 换一张
取 消