Я создал проект C ++ для Windows DLL в Visual Studio 2017. Ниже приведен код, который я написал, пока что ничего, кроме импорта файлов заголовков.
#include "stdafx.h"
#include "windows.h"
#include "ntdsapi.h"
#include "activeds.h"
#pragma comment(lib, "ntdsapi.lib")
#pragma comment(lib, "activeds.lib")
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
Когда я пытался скомпилировать,Я получаю много ошибок в заголовках ntdsapi.h и activeds.h.Но, похоже, это работает нормально, когда я использовал те же заголовки в консольном проекте Windows C ++.
Мне нужно использовать функции Active Directory, определенные в заголовках ntdsapi.h и activeds.h.
Ниже приведен список ошибок:
1>dllmain.cpp
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(924): error C2061: syntax error: identifier 'RPC_AUTH_IDENTITY_HANDLE'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(934): error C2061: syntax error: identifier 'RPC_AUTH_IDENTITY_HANDLE'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(960): error C2061: syntax error: identifier 'RPC_AUTH_IDENTITY_HANDLE'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(971): error C2061: syntax error: identifier 'RPC_AUTH_IDENTITY_HANDLE'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(996): error C2061: syntax error: identifier 'RPC_AUTH_IDENTITY_HANDLE'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1008): error C2061: syntax error: identifier 'RPC_AUTH_IDENTITY_HANDLE'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1036): error C2061: syntax error: identifier 'RPC_AUTH_IDENTITY_HANDLE'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1050): error C2061: syntax error: identifier 'RPC_AUTH_IDENTITY_HANDLE'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1148): error C2061: syntax error: identifier 'RPC_AUTH_IDENTITY_HANDLE'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1159): error C2061: syntax error: identifier 'RPC_AUTH_IDENTITY_HANDLE'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1172): error C2065: 'RPC_AUTH_IDENTITY_HANDLE': undeclared identifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1173): error C2146: syntax error: missing ')' before identifier 'AuthIdentity'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1531): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1531): error C2143: syntax error: missing ',' before '*'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1542): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1542): error C2143: syntax error: missing ',' before '*'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1724): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1724): error C2143: syntax error: missing ',' before '*'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1740): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1740): error C2143: syntax error: missing ',' before '*'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1794): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1794): error C2143: syntax error: missing ',' before '*'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1806): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(1806): error C2143: syntax error: missing ',' before '*'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2611): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2611): error C2143: syntax error: missing ',' before '*'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2621): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2621): error C2143: syntax error: missing ',' before '*'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2707): error C3646: 'uuidNamingContextObjGuid': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2707): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2708): error C3646: 'uuidSourceDsaObjGuid': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2708): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2709): error C3646: 'uuidSourceDsaInvocationID': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2709): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2710): error C3646: 'uuidAsyncIntersiteTransportObjGuid': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2710): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2731): error C3646: 'uuidNamingContextObjGuid': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2731): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2732): error C3646: 'uuidSourceDsaObjGuid': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2732): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2733): error C3646: 'uuidSourceDsaInvocationID': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2733): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2734): error C3646: 'uuidAsyncIntersiteTransportObjGuid': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2734): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2757): error C3646: 'uuidSourceDsaInvocationID': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2757): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2762): error C3646: 'uuidSourceDsaInvocationID': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2762): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2768): error C3646: 'uuidSourceDsaInvocationID': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2768): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2776): error C3646: 'uuidSourceDsaInvocationID': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2776): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2818): error C3646: 'uuidLastOriginatingDsaInvocationID': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2818): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2827): error C3646: 'uuidLastOriginatingDsaInvocationID': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2827): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2838): error C3646: 'uuidLastOriginatingDsaInvocationID': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2838): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2866): error C3646: 'uuidDsaObjGuid': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2866): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2875): error C3646: 'uuidDsaObjGuid': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2875): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2912): error C3646: 'uuidNamingContextObjGuid': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2912): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2913): error C3646: 'uuidDsaObjGuid': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2913): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2930): error C3646: 'uuidNamingContextObjGuid': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2930): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2931): error C3646: 'uuidDsaObjGuid': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2931): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2957): error C3646: 'uuidLastOriginatingDsaInvocationID': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2957): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2975): error C3646: 'uuidLastOriginatingDsaInvocationID': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2975): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2994): error C3646: 'uuidLastOriginatingDsaInvocationID': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(2994): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(3013): error C3646: 'uuidLastOriginatingDsaInvocationID': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(3013): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(3029): error C3646: 'uuidLastOriginatingDsaInvocationID': unknown override specifier
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(3029): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(3091): error C2061: syntax error: identifier 'UUID'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(3103): error C2061: syntax error: identifier 'UUID'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(3143): error C2061: syntax error: identifier 'RPC_AUTH_IDENTITY_HANDLE'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\ntdsapi.h(3157): error C2061: syntax error: identifier 'RPC_AUTH_IDENTITY_HANDLE'
1>Done building project "AdDll.vcxproj" -- FAILED.