const
discVerb = '禁用(&B)';
connVerb = '启用(&A)'; function TForm1.DisableEthernet(const EthName,State: String): Boolean;
var
cpFolder: Folder;
nwFolder: Folder;
nVerbs: FolderItemVerbs;
i,j,k: integer;
aItem: TListItem;
begin
result := false;
cpFolder := Form1.shell1.NameSpace(3);
if cpFolder <> nil then
begin
for i := 0 to cpFolder.items.Count-1 do
begin
if cpFolder.Items.Item(i).Name = '网络和拨号连接' then
begin
nwFolder := cpFolder.items.item(i).GetFolder as Folder;
if nwFolder <> nil then
begin
for j :=0 to nwFolder.items.Count-1 do
begin
if nwFolder.Items.Item(j).Name = EthName then
begin
nVerbs := nwFolder.Items.Item(j).Verbs;
for k := 0 to nVerbs.Count-1 do
begin
if nVerbs.Item(k).Name = State then
begin
nVerbs.Item(k).DoIt;
aItem := Form1.lvLog.Items.Add;
aItem.Caption := FormatDateTime('yyyy-mm-dd hh:mm:ss',now);
aItem.SubItems.Add(EthName);
aItem.SubItems.Add(State);
Result := True;
end;
end;
end;
end;
end;
end;
end;
if nwFolder = nil then
showmessage('Network and Dial-up Connections not found');
end
else
showmessage('control panel not found'); end;报错如下
[Error] Unit1.pas(27): Undeclared identifier: 'Folder'
[Error] Unit1.pas(29): Undeclared identifier: 'FolderItemVerbs'
[Error] Unit1.pas(31): Undeclared identifier: 'TListItem'
[Error] Unit1.pas(34): Undeclared identifier: 'shell1'
[Error] Unit1.pas(35): Operator not applicable to this operand type
[Error] Unit1.pas(37): 'DO' expected but identifier 'items' found
[Error] Unit1.pas(39): 'THEN' expected but identifier 'Items' found
[Error] Unit1.pas(41): Missing operator or semicolon
[Error] Unit1.pas(41): Missing operator or semicolon
[Error] Unit1.pas(41): Operator not applicable to this operand type
[Error] Unit1.pas(42): Operator not applicable to this operand type
[Error] Unit1.pas(44): 'DO' expected but identifier 'items' found
[Error] Unit1.pas(46): 'THEN' expected but identifier 'Items' found
[Error] Unit1.pas(48): Missing operator or semicolon
[Error] Unit1.pas(48): Missing operator or semicolon
[Error] Unit1.pas(49): 'DO' expected but identifier 'Count' found
[Error] Unit1.pas(51): 'THEN' expected but identifier 'Item' found
[Error] Unit1.pas(53): Missing operator or semicolon
[Error] Unit1.pas(54): Undeclared identifier: 'lvLog'
[Error] Unit1.pas(54): Missing operator or semicolon
[Error] Unit1.pas(55): Missing operator or semicolon
[Error] Unit1.pas(56): Missing operator or semicolon
[Error] Unit1.pas(57): Missing operator or semicolon
[Error] Unit1.pas(66): Operator not applicable to this operand type
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
discVerb = '禁用(&B)';
connVerb = '启用(&A)'; function TForm1.DisableEthernet(const EthName,State: String): Boolean;
var
cpFolder: Folder;
nwFolder: Folder;
nVerbs: FolderItemVerbs;
i,j,k: integer;
aItem: TListItem;
begin
result := false;
cpFolder := Form1.shell1.NameSpace(3);
if cpFolder <> nil then
begin
for i := 0 to cpFolder.items.Count-1 do
begin
if cpFolder.Items.Item(i).Name = '网络和拨号连接' then
begin
nwFolder := cpFolder.items.item(i).GetFolder as Folder;
if nwFolder <> nil then
begin
for j :=0 to nwFolder.items.Count-1 do
begin
if nwFolder.Items.Item(j).Name = EthName then
begin
nVerbs := nwFolder.Items.Item(j).Verbs;
for k := 0 to nVerbs.Count-1 do
begin
if nVerbs.Item(k).Name = State then
begin
nVerbs.Item(k).DoIt;
aItem := Form1.lvLog.Items.Add;
aItem.Caption := FormatDateTime('yyyy-mm-dd hh:mm:ss',now);
aItem.SubItems.Add(EthName);
aItem.SubItems.Add(State);
Result := True;
end;
end;
end;
end;
end;
end;
end;
if nwFolder = nil then
showmessage('Network and Dial-up Connections not found');
end
else
showmessage('control panel not found'); end;报错如下
[Error] Unit1.pas(27): Undeclared identifier: 'Folder'
[Error] Unit1.pas(29): Undeclared identifier: 'FolderItemVerbs'
[Error] Unit1.pas(31): Undeclared identifier: 'TListItem'
[Error] Unit1.pas(34): Undeclared identifier: 'shell1'
[Error] Unit1.pas(35): Operator not applicable to this operand type
[Error] Unit1.pas(37): 'DO' expected but identifier 'items' found
[Error] Unit1.pas(39): 'THEN' expected but identifier 'Items' found
[Error] Unit1.pas(41): Missing operator or semicolon
[Error] Unit1.pas(41): Missing operator or semicolon
[Error] Unit1.pas(41): Operator not applicable to this operand type
[Error] Unit1.pas(42): Operator not applicable to this operand type
[Error] Unit1.pas(44): 'DO' expected but identifier 'items' found
[Error] Unit1.pas(46): 'THEN' expected but identifier 'Items' found
[Error] Unit1.pas(48): Missing operator or semicolon
[Error] Unit1.pas(48): Missing operator or semicolon
[Error] Unit1.pas(49): 'DO' expected but identifier 'Count' found
[Error] Unit1.pas(51): 'THEN' expected but identifier 'Item' found
[Error] Unit1.pas(53): Missing operator or semicolon
[Error] Unit1.pas(54): Undeclared identifier: 'lvLog'
[Error] Unit1.pas(54): Missing operator or semicolon
[Error] Unit1.pas(55): Missing operator or semicolon
[Error] Unit1.pas(56): Missing operator or semicolon
[Error] Unit1.pas(57): Missing operator or semicolon
[Error] Unit1.pas(66): Operator not applicable to this operand type
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货