关于网卡的金庸和启用,请问下面这段代码为什么在delphi7中报错
时间:2011-09-09
来源:互联网
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'
作者: chuhonglu 发布时间: 2011-09-09
网卡的金庸?估计金庸可能会用网卡,但网卡的金庸就不清楚了
作者: sonicer 发布时间: 2011-09-09
不好意思,应该是 网卡的禁用和启用问题,麻烦各位看一下上面那段代码错在哪里,谢谢
作者: chuhonglu 发布时间: 2011-09-09
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28