第一次用c,一点头绪也没有、
有一段代码,第一次用vc,我真不知道怎么用……
private bool SetNetworkAdapter(bool status)
{
const string discVerb = "禁用(&B)";
const string connVerb = "启用(&A)";
const string networkConnection = "网络连接";
string sVerb;
if (status) sVerb = connVerb;
else sVerb = discVerb;
Shell32.Shell sh = new Shell32.Shell();
Shell32.Folder folder;
folder = sh.NameSpace(3); //Shell32.ShellSpecialFolderConstants.ssfCONTROLS
try
{
foreach (Shell32.FolderItem myItem in folder.Items())
{
if (myItem.Name == networkConnection)
{
Shell32.Folder fd = (Folder)myItem.GetFolder;
foreach (Shell32.FolderItem fi in fd.Items())
{
if (fi.Name.IndexOf("VMware") > -1)
{
foreach (Shell32.FolderItemVerb Fib in fi.Verbs())
{
// listBox1.Items.Add(Fib.Name);
if (Fib.Name == sVerb)
{
Fib.DoIt();
break;
}
}
}
}
}
}
}
catch (Exception e)
{
//sbpnl2.Text = e.Message;
MessageBox.Show(e.Message);
return false;
}
return true;
}