【发布时间】:2014-08-13 00:10:27
【问题描述】:
我正在尝试使用GetNamedSecurityInfo(),但我不断出现超出范围的错误:
main.cpp:25:3: error: 'SDDL_REVISION_1' was not declared in this scope
SDDL_REVISION_1, DACL_SECURITY_INFORMATION, secDescBuffer, buflen);
^
main.cpp:25:68: error: 'ConvertSecurityDescriptorToStringSecurityDescriptor' was not declared in this scope
SDDL_REVISION_1, DACL_SECURITY_INFORMATION, secDescBuffer, buflen);
代码如下:
#include "windows.h"
#include "sddl.h"
#include "aclapi.h"
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
PACL pACL = NULL;
DWORD dwRes = 0;
PSECURITY_DESCRIPTOR pSecDesc = NULL;
dwRes = GetNamedSecurityInfo(TEXT("C:\\somefile.txt"),
SE_FILE_OBJECT, DACL_SECURITY_INFORMATION,
NULL, NULL, &pACL, NULL, &pSecDesc);
if (ERROR_SUCCESS == dwRes) {
LPTSTR * secDescBuffer = NULL;
PULONG buflen = NULL;
dwRes = ConvertSecurityDescriptorToStringSecurityDescriptor(pSecDesc,
SDDL_REVISION_1, DACL_SECURITY_INFORMATION, secDescBuffer, buflen);
} else {
printf("GetNamedSecurityInfo Error %lu\n", dwRes);
}
...
我知道它使用 sddl.h 头文件,而且它肯定存在,没有直接引用它的编译错误。我在这里想念什么?
编辑: 我正在使用 netbeans 和 minGW 工具链。我有 Windows SDK,并且一直在使用其他部分很好(如示例中所示的 GetNamedSecurityInfo)。
【问题讨论】:
-
一个函数名 51 个字符,有时他们真的做得过火了......
-
我知道对吗?我盯着它看了好几遍,确保没有错字。
-
你有什么版本的 Windows SDK?您包含的 sddl.h 文件是否包含 SDDL_REVISION_1 变量?如果是这样,请检查它周围的#ifdef。
-
尝试更新 MinGW,在旧版本中缺少这些功能。
-
FWIW,您的代码在 Visual Studio 中构建良好。