PC Review


Reply
Thread Tools Rate Thread

Change Folder Icon Programmatically

 
 
Phil Hey
Guest
Posts: n/a
 
      12th Nov 2004
Hi,


I can change the icon for a folder by right clicking on it > going to the
customize tab > and selecting Choose Picture.


Does anyone know if it is possible to do this programmatically from a
windows forms application?


Thanks


Phil


 
Reply With Quote
 
 
 
 
C-Services Holland b.v.
Guest
Posts: n/a
 
      12th Nov 2004
Phil Hey wrote:

> Hi,
>
>
> I can change the icon for a folder by right clicking on it > going to the
> customize tab > and selecting Choose Picture.
>
>
> Does anyone know if it is possible to do this programmatically from a
> windows forms application?
>
>
> Thanks
>
>
> Phil
>
>


Maybe if you change the registry entry at:
hkey_classes_root\folder\DefaultIcon

That where I think the icon definition is stored.
--
Rinze van Huizen
C-Services Holland b.v.
 
Reply With Quote
 
Phil Hey
Guest
Posts: n/a
 
      12th Nov 2004
> Maybe if you change the registry entry at:
> hkey_classes_root\folder\DefaultIcon
>
> That where I think the icon definition is stored.
> --



Yes, but I dont want to change all the folders just certain ones, thanks
anyway

Phil


 
Reply With Quote
 
C-Services Holland b.v.
Guest
Posts: n/a
 
      12th Nov 2004
Phil Hey wrote:

>>Maybe if you change the registry entry at:
>>hkey_classes_root\folder\DefaultIcon
>>
>>That where I think the icon definition is stored.
>>--

>
>
>
> Yes, but I dont want to change all the folders just certain ones, thanks
> anyway
>
> Phil
>
>

I don't think you can since Windows displays the icons according to
filetype. A folder is just a folder to Windows. So it will look up the
icon there and display it. Just like you can't display icon A for one
textfile(.txt) and icon B for another textfile(.txt). So unless you make
a shortcut and change the icon of that I can't see a way.

I might be wrong though, in that case I would love to see how it's done
--
Rinze van Huizen
C-Services Holland b.v.
 
Reply With Quote
 
elziko
Guest
Posts: n/a
 
      12th Nov 2004
Phil Hey wrote:
> I can change the icon for a folder by right clicking on it > going to the
> customize tab > and selecting Choose Picture.


I think if you have an image inside the folder called folder.jpg Windows
will automatically use this for the folder image. You could copy this in
in your code. Not sure if this helps at all.
 
Reply With Quote
 
Phil Hey
Guest
Posts: n/a
 
      12th Nov 2004
Rinze Wrote:
> I don't think you can since Windows displays the icons according to
> filetype.


You can definatelly do this (manually at least) for individual folders
rather than all folders as i am looking at an example of this now. Maybe if
I explain the situation it will help:

I have a drive on the server called Jobs (j in this drive I have folders
for each of the jobs lablled 'J1194' for example. When, in my application, a
job is made in-active i want this folder to appear with a red cross through
it to in dicate that it is closed.

elzico wrote:
> I think if you have an image inside the folder called folder.jpg Windows
> will automatically use this for the folder image. You could copy this in
> in your code. Not sure if this helps at all.


Ok, I have tried this and it works but only if you are viewing the folders
in Thumbnail view not in any of the other views.

Anyway thanks for the help

Phil



 
Reply With Quote
 
=?Utf-8?B?TmlnZWwgQXJtc3Ryb25n?=
Guest
Posts: n/a
 
      12th Nov 2004
Hi Phil

For the Thumbnails view, you should get a picture showing automatically. If
you set an icon for other views, then you get a Desktop.ini file created in
the folder, with this as the content:

[.ShellClassInfo]
IconFile=%SystemRoot%\system32\SHELL32.dll
IconIndex=21

This code creates the file and works...cool!

Dim fs As New IO.FileStream("C:\Test\Desktop.ini", IO.FileMode.Create)
Dim tw As New IO.StreamWriter(fs)
tw.WriteLine("[.ShellClassInfo]")
tw.WriteLine("IconFile=%SystemRoot%\system32\SHELL32.dll")
tw.WriteLine("IconIndex = 21")
tw.Close()
fs.Close()

HTH

Nigel
"Phil Hey" wrote:

> Hi,
>
>
> I can change the icon for a folder by right clicking on it > going to the
> customize tab > and selecting Choose Picture.
>
>
> Does anyone know if it is possible to do this programmatically from a
> windows forms application?
>
>
> Thanks
>
>
> Phil
>
>
>

 
Reply With Quote
 
C-Services Holland b.v.
Guest
Posts: n/a
 
      12th Nov 2004

Phil Hey wrote:
>
> You can definatelly do this (manually at least) for individual folders
> rather than all folders as i am looking at an example of this now. Maybe if
> I explain the situation it will help:
>
> I have a drive on the server called Jobs (j in this drive I have folders
> for each of the jobs lablled 'J1194' for example. When, in my application, a
> job is made in-active i want this folder to appear with a red cross through
> it to in dicate that it is closed.
>


That may be something XP specific I think. On this Win98 computer I
can't change the icon for a specific folder. But elzico might be on to
something.

--
Rinze van Huizen
C-Services Holland b.v.
 
Reply With Quote
 
Phil Hey
Guest
Posts: n/a
 
      12th Nov 2004
Nigel you are an absolute legend, thanks. :-)

One thing of note is that the folder must be a system folder (whatever that
means). Here is a link to a knowledge base article with some info :

http://msdn.microsoft.com/library/de...ing/custom.asp

Phil

"Nigel Armstrong" <(E-Mail Removed)> wrote in
message news:CDC30936-7F9C-42F3-A091-(E-Mail Removed)...
> Hi Phil
>
> For the Thumbnails view, you should get a picture showing automatically.
> If
> you set an icon for other views, then you get a Desktop.ini file created
> in
> the folder, with this as the content:
>
> [.ShellClassInfo]
> IconFile=%SystemRoot%\system32\SHELL32.dll
> IconIndex=21
>
> This code creates the file and works...cool!
>
> Dim fs As New IO.FileStream("C:\Test\Desktop.ini",
> IO.FileMode.Create)
> Dim tw As New IO.StreamWriter(fs)
> tw.WriteLine("[.ShellClassInfo]")
> tw.WriteLine("IconFile=%SystemRoot%\system32\SHELL32.dll")
> tw.WriteLine("IconIndex = 21")
> tw.Close()
> fs.Close()
>
> HTH
>
> Nigel
> "Phil Hey" wrote:
>
>> Hi,
>>
>>
>> I can change the icon for a folder by right clicking on it > going to the
>> customize tab > and selecting Choose Picture.
>>
>>
>> Does anyone know if it is possible to do this programmatically from a
>> windows forms application?
>>
>>
>> Thanks
>>
>>
>> Phil
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change folder icon that can preview images in the folder? yuezhang448 Windows Vista General Discussion 0 18th May 2009 07:50 AM
how can i change Exe icon programmatically. faraz Microsoft VB .NET 3 8th Aug 2007 09:29 PM
can't change customised folder icon back to default XP folder icon =?Utf-8?B?VXplZQ==?= Windows XP Customization 6 4th Feb 2007 11:30 AM
How to change shared folder perms programmatically in user-level mode Scott Kellish Microsoft Windows 2000 Security 1 19th Feb 2006 11:29 AM
programmatically change permissions on folder in windows? brandon Microsoft Windows 2000 Security 2 6th Aug 2004 09:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:30 PM.