function TForm1.ControlEthernet(const EthName, FolderItemVerbsName: String): Boolean; var cpFolder,nwFolder:Folder; //一个外壳文件夹对象 nVerbs:FolderItemVerbs; //获得上下文相关的菜单信息 i,j,k:integer; Shell1:TShell; begin Result:=false; Shell1:=TShell.Create(Application); cpFolder:=Shell1.NameSpace(3); //选择控件面板 if cpFolder<>nil then begin for i:=0 to cpFolder.items.Count-1 do //返回它所包含的外壳对象的集合(文件) 28 begin if cpFolder.Items.Item(i).Name='网络连接' then //返回的集合的名称 begin nwFolder:=cpFolder.items.item(i).GetFolder as Folder; //取得该cpFolder下面的外壳对象 if nwFolder<>nil then //内容不为空 begin for j:=0 to nwFolder.items.Count-1 do //历遍cpFolder下面的外壳对象 begin if nwFolder.Items.Item(j).Name=EthName then //这个就是楼主要的东西 '本地连接' begin
end; end; end; end; end; end; end; ----------------------------------------------------------------------------- delphi 2007 下 Component -> Import ActiveX Control -> Microsoft Shell Contolrs And Automation 然后创建单元文件,之后再新建一个安装包,添加该单元文件,最后是安装该控件,就可以用了(Tshell) 在 D7 下不用这么麻烦,直接导入这个 ActiveX 就,引用这个单元就可以使用了
FolderItemVerbsName: String): Boolean;
var cpFolder,nwFolder:Folder; //一个外壳文件夹对象
nVerbs:FolderItemVerbs; //获得上下文相关的菜单信息
i,j,k:integer;
Shell1:TShell;
begin
Result:=false;
Shell1:=TShell.Create(Application);
cpFolder:=Shell1.NameSpace(3); //选择控件面板
if cpFolder<>nil then
begin
for i:=0 to cpFolder.items.Count-1 do //返回它所包含的外壳对象的集合(文件) 28
begin
if cpFolder.Items.Item(i).Name='网络连接' then //返回的集合的名称
begin
nwFolder:=cpFolder.items.item(i).GetFolder as Folder; //取得该cpFolder下面的外壳对象
if nwFolder<>nil then //内容不为空
begin
for j:=0 to nwFolder.items.Count-1 do //历遍cpFolder下面的外壳对象
begin
if nwFolder.Items.Item(j).Name=EthName then //这个就是楼主要的东西 '本地连接'
begin
end;
end;
end;
end;
end;
end;
end;
-----------------------------------------------------------------------------
delphi 2007 下 Component -> Import ActiveX Control -> Microsoft Shell Contolrs And Automation
然后创建单元文件,之后再新建一个安装包,添加该单元文件,最后是安装该控件,就可以用了(Tshell) 在 D7 下不用这么麻烦,直接导入这个 ActiveX 就,引用这个单元就可以使用了