المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to build visual c++ code



C++ Programming
10-02-2009, 04:31 AM
Dear Experts,

i could not able to build a following visual c++ code.can any one help me?

It shows can not open activeds.h


#define _UNICODE
#pragma comment( lib, "Activeds.lib" )
#pragma comment( lib, "Adsiid.lib" )

#include "stdafx.h"
#include
#include
#include
#include
#include
#include
#include

int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr;
IADsContainer *pCont = NULL;
CoInitialize(NULL);
hr = ADsGetObject(L"WinNT://xxx.com/dc1.yyy.xxx.com", IID_IADsContainer, (void**) &pCont );
if ( !SUCCEEDED(hr) ) { return hr;}
_variant_t var;
IEnumVARIANTPtr pEnum;
ADsBuildEnumerator (pCont,&pEnum);
int cnt=0;
ULONG ulFetched = 0L;
_variant_t vChild;
while((SUCCEEDED(ADsEnumerateNext(pEnum, 1, &vChild, &ulFetched)) && ulFetched==1))
{
IADsUser* pADs;
hr = V_DISPATCH(&vChild)->QueryInterface(IID_IADsUser, (void**)&pADs);
if(hr!=S_OK)
break;
BSTR bstrName;
pADs->get_Name(&bstrName);
CString csName=bstrName;
SysFreeString(bstrName);
printf("%s\n",csName);
pADs->Release();
pADs = NULL;

}

// Cleanup.
if ( pCont )
{
pCont->Release();
}
CoUninitialize();

}

return 0;
}