为啥读不出INI内容呢?
procedure TBandForm.IniMenu;
var
  i, j: integer;
  MI: TMenuItem;
  pMD: TpMenuData;
  Section: string;
  pListItem: TpListItem;
begin
  MainIndex := 0;
  CategoryList := TList.Create;
  ini:=Tinifile.create(AppDir+'\SearchUrl.ini');
  Config.WebSite := ini.ReadInteger('Config','WebSite',0);
  Config.EngineCount := ini.ReadInteger('Config','EngineCount',0);
  Config.WriteLog := ini.ReadInteger('Config','WriteLog',0);
  Config.AutoSearch := ini.ReadInteger('Config','AutoSearch',0);
  SetLength(MD,Config.EngineCount);
  for i := 0 to Config.EngineCount-1 do
  begin
    //new(pMD);
    pMD := @MD[i];
    Section := inttostr(i);
    pMD.Name := ini.ReadString(Section,'Name','');
    pMD.Category := ini.ReadString(Section,'Category','');
    pMD.HomePage := ini.ReadString(Section,'HomePage','');
    pMD.URL := ini.ReadString(Section,'URL','');    GetCategory(pMD.Category);
    for j:= 0 to CategoryList.Count-1 do
    begin
      pListItem := TpListItem(CategoryList.Items[j]);
      if pos(pListItem.Category,pMD.Category)<>0 then  // is this category
      begin
        MI := TMenuItem.Create(self);
        MI.AutoHotkeys := maManual;
        MI.Caption := pMD.Name;
        MI.Tag := integer(pMD);
        MI.OnClick := MyMenuHandler;
        pListItem.menu.Add(MI);      end;
    end;
    
  end;
end;procedure TBandForm.MyMenuHandler(Sender: TObject);
var
  pMD: TpMenuData;
begin
  With sender as TMenuItem do
  begin
    pMD := TpMenuData(tag);
    ShowMessage(pMD.HomePage+#13+pMD.URL);
    tbSearchType.Caption := pMD.Name;
    pCurData := pMD;
    if trim(cbAddr.Text) <> '' then tbGoClick(Self);
  end;
end;procedure TBandForm.GetCategory(s: string);
var
  i, j, len, index: integer;
  ts: string;
  pListItem: TpListItem;
  bExist: boolean;
begin
  ts := '';
  len := length(s);
  index := 0;
  for i := 1 to len do
  begin
    if s[i]<>';' then ts:=ts+s[i];// else inc(index);
    if (s[i]=';')or(i=len) then
    if trim(ts)<>'' then
    begin
      bExist := false;
      for j:= 0 to CategoryList.Count-1 do
      begin
        pListItem := TpListItem(CategoryList.Items[j]);
        if ts = pListItem.Category then
        begin
          bExist := true;
          break;
        end;
      end;
      if not bExist then
      begin
        new(pListItem);
        pListItem.Category := ts;
        pListItem.menu := TMenuItem.Create(self);
        //pListItem.menu.AutoHotkeys := maManual;
        pListItem.menu.Caption := ts;
        //pListItem.menu.ShortCut := ;
        //pListItem.menu.OnClick := MyMenuHandler;
        if index = 0 then
        begin
          mSearch.Insert(MainIndex,pListItem.menu);
          inc(MainIndex);
        end
        else
        mSearch.Add(pListItem.menu);
        CategoryList.Add(pListItem);
      end;
      inc(index);
      ts:='';
    end;
  end;
end;  ------------------------------------------------------------------------------------ini文件的内容是这样的[HKEY_USERS\S-1-5-21-117609710-515967899-725345543-500\Software\BingleToolbar]
"WebSite"=dword:00000002
"EngineCount"=dword:00000011
"WriteLog"=dword:00000001
"AutoSearch"=dword:00000001[HKEY_USERS\S-1-5-21-117609710-515967899-725345543-500\Software\BingleToolbar\0]
"Name"="天网"
"Category"="软件搜索"
"HomePage"="http://bingle.pku.edu.cn/"
"URL"="http://bingle.pku.edu.cn/scripts/ftp_search.exe?word="

解决方案 »

  1.   

    你这是注册表还是INI文件呀?
      

  2.   

    Config.WebSite := ini.ReadInteger('Config','WebSite',0);应该改为
    Config.WebSite := ini.ReadInteger('HKEY_USERS\S-1-5-21-117609710-515967899-725345543-500\Software\BingleToolbar','WebSite',0);
      

  3.   

    好象还是不行~
    'HKEY_USERS\S-1-5-21-117609710-515967899-725345543-500\Software\BingleToolbar这个注册表的东西要不要无所谓吧,主要是读下面这些,
    "Name"="天网"
    "Category"="软件搜索"
    "HomePage"="http://bingle.pku.edu.cn/"
    "URL"="http://bingle.pku.edu.cn/scripts/ftp_search.exe?word="  
      

  4.   

    SetLength(MD,Config.EngineCount);这个MD是什么呀,没声明呢?
    TPMEUNDATA也要定义好象是这个吧
    TPMEUNDATA=RECORD
     Name:STRING; 
     Category:STRING;
     HomePage:STRING;
     URL :STRING;
    ENDini文件也要放到程序目录下
    其他都是程序,你检查下,看哪里还出错
      

  5.   

    都在这声明了~
    type
      TConfig = record
        WebSite: integer;
        EngineCount: integer;
        WriteLog: integer;
        AutoSearch: integer;
      end;  TpMenuData = ^TMenuData;
      TMenuData = record
        Name: string;
        Category: string;
        HomePage: string;
        URL: string;
      end;  TpListItem = ^TListItem;
      TListItem = record
        Category: string;
        menu: TMenuItem;
      end;
      

  6.   

    编译后MI里什么也没出来~
    好象啥也没从INI里读出来~
      

  7.   

    原始代码是这个 http://www.playicq.com/1/2016.html
    麻烦您看一下,谢谢了~
      

  8.   

    "Name"="天网"
    "Category"="软件搜索"
    "HomePage"="http://bingle.pku.edu.cn/"
    "URL"="http://bingle.pku.edu.cn/scripts/ftp_search.exe?word="  
    我是想把这些东西都读到菜单中,它原来的程序中动态的这段也是没出来,里面用的是直接写的一个Menu,能麻烦您帮我改一下么?小弟不胜感激,我可以再加分给您~谢谢了~
      

  9.   

    procedure TForm1.MyAddMenu(Sender: TObject);
    var
      aMD:TMainMenu;
      NewItem:TMenuItem;
      i:Integer;
      MyList:TStringlist;
    begin
      Mylist:=TStringList.Create;
      MyLIst.Add('ss'); //如果你想从ini读,那么把ini里信息保存到这里也行,自己看着转化吧,
      MyLIst.Add('ddd');
      MyList.Add('saff');
      aMD:=TMainMenu.Create(Self);
      for i:=0 to Mylist.Count-1 do
      begin
        NewItem:=TMenuItem.Create(Self);
        NewItem.Caption:=MyList.Strings[i];
        if aMD.Items.Count=0 then
          aMD.Items.Add(NewItem)
        else
          aMD.Items.Items[0].Add(NewItem);
      end;
    end;
      

  10.   

    改ini文件:[config]
    "WebSite"=dword:00000002
    "EngineCount"=dword:00000011
    "WriteLog"=dword:00000001
    "AutoSearch"=dword:00000001[sectionname]
    "Name"="天网"
    "Category"="软件搜索"
    "HomePage"="http://bingle.pku.edu.cn/"
    "URL"="http://bingle.pku.edu.cn/scripts/ftp_search.exe?word="你主要是从文件读取的函数参数不熟,搞清楚参数含义就没问题了.
      

  11.   

    怎么好象还是不行~,我现在只读这些内容~
    [section]
    "Name"="天网"
    "Category"="软件搜索"
    "HomePage"="http://bingle.pku.edu.cn/"
    "URL"="http://bingle.pku.edu.cn/scripts/ftp_search.exe?word="是不是这里有问题:
    for i := 0 to Config.EngineCount-1 do
      begin
        //new(pMD);
        pMD := @MD[i];
        Section := inttostr(i);
        pMD.Name := ini.ReadString(Section,'Name','');
        pMD.Category := ini.ReadString(Section,'Category','');
        pMD.HomePage := ini.ReadString(Section,'HomePage','');
        pMD.URL := ini.ReadString(Section,'URL','');    GetCategory(pMD.Category);
        for j:= 0 to CategoryList.Count-1 do
        begin
          pListItem := TpListItem(CategoryList.Items[j]);
          if pos(pListItem.Category,pMD.Category)<>0 then  // is this category
          begin
            MI := TMenuItem.Create(self);
            MI.AutoHotkeys := maManual;
            MI.Caption := pMD.Name;
            MI.Tag := integer(pMD);
            MI.OnClick := MyMenuHandler;
            pListItem.menu.Add(MI);      end;
        end;