问题描述
我正在研究VS2010 C ++项目。我正面临一个新的项目构建问题,其中CreateFileA函数无法打开指定的文件。但如果我将share_mode更改为FILE_SHARE_READ(0x00000001),则可以正常工作。但是在生产代码中,我将
的share_mode值作为MY_DEFAULT_OPEN_PERMS(0666)运行良好。
I am working on VS2010 C++ project. I am facing a issue for a fresh build of project where CreateFileA function fails to open the specified file. but If I change the share_mode to FILE_SHARE_READ(0x00000001) it works. But in production code I have the value for share_mode as MY_DEFAULT_OPEN_PERMS (0666) which is working well.
您对此有何看法?
Do you have any thought on this?
-------------------------------------- -------------------------------------------------- -----------------------------
---------------------------------------------------------------------------------------------------------------------
#define MY_DEFAULT_FILE_PERMS 0666
$
HANDLE htempFile = NULL;
// DWORD share_mode = FILE_SHARE_READ;
DWORD share_mode = MY_DEFAULT_OPEN_PERMS;
htempFile = CreateFileA(insFile.c_str(),GENERIC_READ,share_mode,NULL,OPEN_EXISTING,0,NULL);
#define MY_DEFAULT_FILE_PERMS 0666
HANDLE htempFile = NULL;
//DWORD share_mode = FILE_SHARE_READ;
DWORD share_mode = MY_DEFAULT_OPEN_PERMS;
htempFile = CreateFileA(insFile.c_str(), GENERIC_READ, share_mode, NULL, OPEN_EXISTING, 0,NULL);
--------------- -------------------------------------------------- -------------------------------------------------- -
---------------------------------------------------------------------------------------------------------------------
推荐答案
这篇关于CreateFileA无法打开xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!