+ -
当前位置:首页 → 问答吧 → 关于网卡的金庸和启用,请问下面这段代码为什么在delphi7中报错

关于网卡的金庸和启用,请问下面这段代码为什么在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'

作者: chuhonglu   发布时间: 2011-09-09

网卡的金庸?估计金庸可能会用网卡,但网卡的金庸就不清楚了

作者: sonicer   发布时间: 2011-09-09

不好意思,应该是 网卡的禁用和启用问题,麻烦各位看一下上面那段代码错在哪里,谢谢

作者: chuhonglu   发布时间: 2011-09-09

热门下载

更多