Title: Changing hard drive's icon under Windows XP
Question: How to change drive icon in My Computer under Windows XP?
Answer:
This article shows that how can changing a driver icon in MyComputer under
WinXP. This modification is so different than Win9x and not easy.
As you know that you have so many articles that just change some settings
in the registry in D3K database, but the following registry codes are
undocumanted and you don't see it normally in XP Registry.
if you can want to change your hard driver icon then insert the following
code into Button1's OnClick event. I hope this be usefull for someone.
add Registry in USES clause
procedure TForm1.Button1Click(Sender: TObject);
var Reg: TRegistry;
begin
Reg := TRegistry.Create;
try
with Reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
OpenKey
('Software\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\', True);
{ True, because if a subkey named DriveIcons and/or DefaultIcon
does not exist, windows automatically creates it }
OpenKey('C\DefaultIcon\', True); // as default first drive C
// we are choosing empty field as default value
WriteString('', 'C:\YourIcons\Sample1.ico');
{ and icon file path or if dll file then
e.g 'c:\YourIcons\Icons.dll, 2' }
CloseKey;
end;
finally
Reg.Free;
end;
// if 2nd hard drive is present..
Reg := TRegistry.Create;
try
with Reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
OpenKey
('Software\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\', True);
OpenKey('D\DefaultIcon\', True);
WriteString('', 'C:\YourIcons\Sample2.ico');
CloseKey;
end;
finally
Reg.Free;
end;
end;
in the same way, you can write these techniques for another drivers.
Now, hard drive's icon have been changed. Press F5 on the keyboard
or reboot for the changes to take effect.