- 积分
- 6483
- 明经币
- 个
- 注册时间
- 2002-4-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2005-5-28 21:33:00
|
显示全部楼层
将菜单组加入注册表一般用LISP或VBA实现比较保险。我的新的安装程序并不做这个工作。直接修改注册表的做法我只能给你一个Delphi的例子,仅供参考:- procedure RemoveMenuGroup(const AutoCADProductKey, MenuGroup:String);
- var Profiles: TStringList;
- MenuGroupValues: TStringList;
- i,j:integer;
- MenuGroupFound: boolean;
- Reg: TRegistry;
- begin
- MenuGroupFound:=false;
- Profiles:= TStringList.Create;
- MenuGroupValues := TStringList.Create;
- Reg:=TRegistry.Create;
- try
- Reg.RootKey := HKCU;
- Reg.OpenKey(AutoCADProductKey+'\Profiles', false);
- Reg.GetKeyNames(Profiles);
- Reg.CloseKey;
- for i := 0 to Profiles.Count-1 do
- begin
- if Reg.KeyExists(AutoCADProductKey+'\Profiles\'+Profiles[i]+'\Menus') then
- begin
- MenuGroupValues.Clear;
- Reg.OpenKey(AutoCADProductKey+'\Profiles\'+Profiles[i]+'\Menus', true);
- j := 1;
- While Reg.ValueExists('Group'+IntToStr(j)) do
- begin
- MenuGroupValues.Add(Reg.ReadString('Group'+IntToStr(j)));
- inc(j);
- end;
- for j := MenuGroupValues.Count - 1 downto 0 do
- begin
- if UpperCase(MenuGroupValues[j]) = UpperCase(MenuGroup) then
- begin
- MenuGroupValues.Delete(j);
- MenuGroupFound:=true;
- end;
- end;
- If MenuGroupFound then
- begin
- j:=1;
- While Reg.ValueExists('Group'+IntToStr(j)) do
- begin
- Reg.DeleteValue('Group'+IntToStr(j));
- inc(j);
- end;
- for j := 0 to MenuGroupValues.Count -1 do
- begin
- Reg.WriteString('Group'+IntToStr(j+1), MenuGroupValues[j]);
- end;
- end;
- Reg.CloseKey;
- end;
- end;
- finally
- Profiles.Free;
- MenuGroupValues.Free;
- Reg.Free;
- end;
- end;
- procedure AddMenuGroup(const AutoCADProductKey, MenuGroup:String);
- var Profiles: TStringList;
- i,j:integer;
- Reg: TRegistry;
- begin
- RemoveMenuGroup(AutoCADProductKey, MenuGroup);
- Profiles:= TStringList.Create;
- Reg := TRegistry.Create;
- try
- Reg.RootKey := HKCU;
- Reg.OpenKey(AutoCADProductKey+'\Profiles', false);
- Reg.GetKeyNames(Profiles);
- Reg.CloseKey;
- for i := 0 to Profiles.Count-1 do
- begin
- if Reg.KeyExists(AutoCADProductKey+'\Profiles\'+Profiles[i]+'\Menus') then
- begin
- Reg.OpenKey(AutoCADProductKey+'\Profiles\'+Profiles[i]+'\Menus', true);
- j:=1;
- While Reg.ValueExists('Group'+IntToStr(j))
- and (Reg.ReadString('Group'+IntToStr(j)) <> '') do inc(j);
- Reg.WriteString('Group'+IntToStr(j), MenuGroup);
- Reg.CloseKey;
- end;
- end;
- finally
- Profiles.Free;
- Reg.Free;
- end;
- end;
复制代码 |
|