如何用VC.net做个可执行程序,建立一个IIS虚拟目录!?

fitman1981 2003-10-18 06:07:36
我用VC.net的时候为什么DirectoryEntry总是识别不了
应该怎么样使用DirectoryEntry类啊!!
能不能给段代码,谢谢各位大哥了!
...全文
31 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
poweruser 2003-10-18
  • 打赏
  • 举报
回复
如果需要更多的信息请在msdn里面搜索DirectoryEntry

看你的错误情况应该是没有添加这几句代码
#using <system.directoryservices.dll>

using namespace System;
using namespace System::DirectoryServices;
poweruser 2003-10-18
  • 打赏
  • 举报
回复
msdn里面的例子
#include "stdafx.h"

#using <mscorlib.dll>
#using <System.dll>
#using <system.directoryservices.dll>

#include <tchar.h>

using namespace System;
using namespace System::DirectoryServices;


// This is the entry point for this application.
int _tmain(void)
{
try
{
//Build the path, and then bind to computer.
String *adsPath = String::Format(S"WinNT://{0},computer", Environment::MachineName);
DirectoryEntry *computerEntry = new DirectoryEntry(adsPath);

DirectoryEntry *userEntry = computerEntry->Children->Add(S"TestUser1", S"user");
userEntry->Properties->get_Item(S"Description")->Add(S"Test user from .NET");

//Set the password, and then commit the changes.
String *stringArray[] = new String *[1];
stringArray[0] = S"#12353Abc";
userEntry->Invoke(S"SetPassword", stringArray);
userEntry->CommitChanges();

//Add the new user to a group.
DirectoryEntry *groupEntry = computerEntry->Children->Find(S"Administrators");
stringArray[0] = userEntry->Path;
groupEntry->Invoke(S"Add", stringArray);
}
catch(Exception *e)
{
Console::WriteLine(e);
}

return 0;
}

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧