CreateFile2 returns access denied error in Windows 8
Posted
by
Liton
on Stack Overflow
See other posts from Stack Overflow
or by Liton
Published on 2012-08-28T02:39:18Z
Indexed on
2012/08/28
3:38 UTC
Read the original article
Hit count: 178
I have written the following lines of code to open a file under InstalledFolder directory:
Platform::String^ locationPath = Platform::String::Concat(Package::Current->InstalledLocation->Path, "\\Assets\\Logo.png");
CREATEFILE2_EXTENDED_PARAMETERS extendedParams = {0};
extendedParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
extendedParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
extendedParams.dwFileFlags = FILE_FLAG_SEQUENTIAL_SCAN;
extendedParams.dwSecurityQosFlags = SECURITY_ANONYMOUS;
extendedParams.lpSecurityAttributes = nullptr;
extendedParams.hTemplateFile = nullptr;
Wrappers::FileHandle file(
CreateFile2(
locationPath->Data(),
GENERIC_READ,
0,
OPEN_EXISTING,
&extendedParams
)
);
DWORD e = GetLastError();
if (file.Get() == INVALID_HANDLE_VALUE)
{
throw ref new Platform::FailureException();
}
The CreateFile2 returns access denied error. Can anyone please help me out?
Thanks,
© Stack Overflow or respective owner