注册表的问题(50分)

  • 主题发起人 peterluolaw
  • 开始时间
P

peterluolaw

Unregistered / Unconfirmed
GUEST, unregistred user!
请问各位,我用下面的代码对注册表进行修改,但发现
Registry.WriteString('TileWallPaper', ...) 以及
Registry.WriteString('WallPaperStyle', ...)无法
更改相应的键值,但下面的两个语句又能够更改相应的
键值:Registry.WriteString('wallpaper','c:/windows/temp/tmp.bmp')和
Registry.WriteString('wallpaper',filelistbox1.FileName).
请问到底是什么问题?

procedure TForm1.Button4Click(Sender: TObject);
var
tmpbmp: tbitmap;
Registry: TRegistry;
begin
tmpbmp:=tbitmap.Create;
Registry := TRegistry.Create;
Registry.RootKey:=HKEY_CURRENT_USER;
Registry.OpenKey('Control Panel/DeskTop', true);

if radiogroup1.ItemIndex=0 then
begin
Registry.WriteString('TileWallPaper', '0');
Registry.WriteString('WallPaperStyle', '0');
// 居中方式,WallPaperStyle为0
end;

if radiogroup1.ItemIndex=1 then
begin
Registry.WriteString('TileWallPaper', '1');
Registry.WriteString('WallPaperStyle', '0');
// 平铺方式,WallPaperStyle为0
end;;

if radiogroup1.ItemIndex=1 then
begin
Registry.WriteString('TileWallPaper', '0');
Registry.WriteString('WallPaperStyle', '2');
// 拉伸方式,WallPaperStyle为0
end;
if (pos('.jpg',filelistbox1.FileName)>1) or (pos('.jpeg',filelistbox1.FileName)>1) or (pos('.JPG',filelistbox1.FileName)>1) or (pos('.JPEG',filelistbox1.FileName)>1) then
begin
tmpbmp.assign(image1.picture.Graphic);
tmpbmp.SaveToFile('c:/windows/temp/tmp.bmp');
Registry.WriteString('wallpaper','c:/windows/temp/tmp.bmp');
end
else
Registry.WriteString('wallpaper',filelistbox1.FileName);
Registry.CloseKey;
Registry.Free;
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, nil, SPIF_SENDCHANGE);
tmpbmp.Free;
end;
 
顶部