急求!使用ABO或ADSI建立website的c++代码 小弟需要使用ABO或ADSI建立website,但用c++实现的文档很少,哪位高手能指点一下啊!需要建立IIsWebServer和IIsWebVirtualDir,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //VC6.0+SP5, SDK200210, windows 2000 server#include <windows.h>#include <Iads.h>#include <comdef.h>#include <tchar.h>#include <stdio.h>#include <Adshlp.h>#pragma comment(lib,"ActiveDS")#pragma comment(lib,"adsiid")BOOL CreateWebServer(LPCTSTR bindaddress,LPCTSTR domain,LPCTSTR DiskPath);void main(){CoInitialize(NULL);if(TRUE==CreateWebServer(_T("192.168.0.224:80"),_T("www.masterz.com"),_T("d:\\tmp")))printf("create site ok\n");elseprintf("create site failed\n");CoUninitialize();}BOOL CreateWebServer(LPCTSTR bindaddress,LPCTSTR domain,LPCTSTR pathname){if(bindaddress==NULL||NULL==domain||NULL==pathname)return FALSE;IADsContainer *pCont=NULL;IADs* pAds=NULL;IADs* pVrAds=NULL;IADsServiceOperations *pSrvOp=NULL;IDispatch *pDisp = NULL;IDispatch *pVrDisp = NULL;_bstr_t WNumer="123";_bstr_t newBindings=_bstr_t(bindaddress)+":"+domain;HRESULT hr;if(ADsGetObject(L"IIS://localhost/w3svc",IID_IADsContainer,(void**)&pCont)==S_OK){if(pCont->Create(L"IIsWebServer",WNumer,&pDisp)==S_OK){hr=pDisp->QueryInterface(IID_IADs, (void**)&pAds);hr=pDisp->QueryInterface(IID_IADsServiceOperations, (void**)&pSrvOp);pAds->Put(L"ServerSize",_variant_t(long(1)));pAds->Put(L"ServerComment",_variant_t(_bstr_t("masterz")));pAds->Put(L"ServerBindings",_variant_t(newBindings));pAds->SetInfo();hr=pCont->GetObject(L"IIsWebServer",(WNumer),&pDisp);if(pDisp->QueryInterface(IID_IADsContainer,(void**)&pCont)==S_OK){if(pCont->Create(L"IIsWebVirtualDir",L"Root",&pVrDisp)==S_OK){hr=pVrDisp->QueryInterface(IID_IADs, (void**)&pVrAds);pVrAds->Put(L"AccessRead",_variant_t(true));pVrAds->Put(L"AccessWrite",_variant_t(true));pVrAds->Put(L"AccessScript",_variant_t(true));pVrAds->Put(L"EnableDirBrowsing",_variant_t(true));pVrAds->Put(L"Path",_variant_t(pathname));pVrAds->Put(L"AppRoot",_variant_t(pathname));pVrAds->SetInfo();pVrAds->Release();pAds->Release();pCont->Release();}hr=pSrvOp->Start();hr=pSrvOp->Release();}}}return true;} 多谢masterz兄,虽然小弟已找到ADSI的代码,但还是非常感谢…… :) 我想请问下现在那些漂亮的软件是如何做的界面美化? VC初学者求助 写一个要求超多的系统 自定义类的使用 还是水晶报表的问题 关于窗口置于桌面顶层的问题,以及toolbar的效果 求助,举手之劳 微调按钮不能在工具条上显示? 如何获得数据源中的所有表名 如何Disable工具栏按钮 文件调用 drawtext的问题 类与类相互包含怎么办?
#include <windows.h>
#include <Iads.h>
#include <comdef.h>
#include <tchar.h>
#include <stdio.h>
#include <Adshlp.h>
#pragma comment(lib,"ActiveDS")
#pragma comment(lib,"adsiid")
BOOL CreateWebServer(LPCTSTR bindaddress,LPCTSTR domain,LPCTSTR DiskPath);
void main()
{
CoInitialize(NULL);
if(TRUE==CreateWebServer(_T("192.168.0.224:80"),_T("www.masterz.com"),_T("d:\\tmp")))
printf("create site ok\n");
else
printf("create site failed\n");
CoUninitialize();
}
BOOL CreateWebServer(LPCTSTR bindaddress,LPCTSTR domain,LPCTSTR pathname)
{
if(bindaddress==NULL||NULL==domain||NULL==pathname)
return FALSE;
IADsContainer *pCont=NULL;
IADs* pAds=NULL;
IADs* pVrAds=NULL;
IADsServiceOperations *pSrvOp=NULL;
IDispatch *pDisp = NULL;
IDispatch *pVrDisp = NULL;
_bstr_t WNumer="123";
_bstr_t newBindings=_bstr_t(bindaddress)+":"+domain;
HRESULT hr;
if(ADsGetObject(L"IIS://localhost/w3svc",IID_IADsContainer,(void**)&pCont)==S_OK)
{
if(pCont->Create(L"IIsWebServer",WNumer,&pDisp)==S_OK)
{
hr=pDisp->QueryInterface(IID_IADs, (void**)&pAds);
hr=pDisp->QueryInterface(IID_IADsServiceOperations, (void**)&pSrvOp);
pAds->Put(L"ServerSize",_variant_t(long(1)));
pAds->Put(L"ServerComment",_variant_t(_bstr_t("masterz")));
pAds->Put(L"ServerBindings",_variant_t(newBindings));
pAds->SetInfo();hr=pCont->GetObject(L"IIsWebServer",(WNumer),&pDisp);
if(pDisp->QueryInterface(IID_IADsContainer,(void**)&pCont)==S_OK)
{
if(pCont->Create(L"IIsWebVirtualDir",L"Root",&pVrDisp)==S_OK)
{
hr=pVrDisp->QueryInterface(IID_IADs, (void**)&pVrAds);
pVrAds->Put(L"AccessRead",_variant_t(true));
pVrAds->Put(L"AccessWrite",_variant_t(true));
pVrAds->Put(L"AccessScript",_variant_t(true));
pVrAds->Put(L"EnableDirBrowsing",_variant_t(true));
pVrAds->Put(L"Path",_variant_t(pathname));
pVrAds->Put(L"AppRoot",_variant_t(pathname));
pVrAds->SetInfo();
pVrAds->Release();
pAds->Release();
pCont->Release();
}
hr=pSrvOp->Start();
hr=pSrvOp->Release();
}
}
}
return true;
}