View Full Version : Folder.Create -- is it possible to some how create a folder with a specific icon?
Nocturnal
06-03-2006, 08:22 PM
Thanks in advance.
Just to clarify, I don't want to create a shortcut but rather when I create a folder in the Documents and Settings\All Users\Desktop folder, I'd like to be able to choose an icon to go with that folder if they're using XP.
Wonderboy
06-03-2006, 09:30 PM
No i dont think changing the icon is possible, atleast not by only using ams am afraid.
Iam not sure if you could use some regkey to do it.maby
Nocturnal
06-03-2006, 11:18 PM
Ok using the Zip.Extract function and having it extract a .zip file which includes a folder along with a desktop.ini file in it, I am thinking this should work but this is not the case. Any ideas as to why this isn't happening? Shouldn't the desktop.ini automatically be picked up as far as the icon settings go by Windows?
Intrigued
06-04-2006, 02:45 AM
Don't forget to pass the attrib +s argument. As that sets the folder's attribute to System (which is needed in order to have the .ico file swapped out to what you want).
To test this:
Copy the folder with your .ico and .ini file to the Desktop (if it's not there already). Then click START>RUN>(type) attrib +s "ExactPathToFolder-IncludeTheseDoubleQuotes!">click the ENTER key.
Nocturnal
06-04-2006, 03:11 AM
Don't forget to pass the attrib +s argument. As that sets the folder's attribute to System (which is needed in order to have the .ico file swapped out to what you want).
To test this:
Copy the folder with your .ico and .ini file to the Desktop (if it's not there already). Then click START>RUN>(type) attrib +s "ExactPathToFolder-IncludeTheseDoubleQuotes!">click the ENTER key.
How would you go about adding that attrib using AMS?
Nocturnal
06-04-2006, 03:34 AM
Ok this is what I have so far:
Zip.Extract("AutoPlay\\Docs\\sg.zip", {"*.*"}, _DesktopFolderCommon, true, true, "", 3, nil);
-- get the file's current attributes
attrib = File.GetAttributes( _DesktopCommonFolder .. "\\Folder1" );
-- override a couple of values in the table
attrib.System = true;
-- set the modified attributes back to the file
File.SetAttributes( _DesktopCommonFolder .. "\\Folder1", attrib );
So initially I have a button in which if clicked on, it will unzip this particular folder which already includes a desktop.ini and the icon file. Then, I am trying to set the attrib of the folder to System so that my icon will show up. Am I missing something? I get an error with line four when I try to preview the program.
Nocturnal
06-04-2006, 03:52 AM
So what I'm trying to work with now is after having it unzip the files to the desktop, having it also run a batch file which gives the folder attrib +s. But I'm having one **** of a hard time doing this. Any help is appreciated.
To customize a folder, there is a special file 'desktop.ini' within it which holds the custiomization data, including custom icon.
For example, desktop.ini file could contain:
[.ShellClassInfo]
IconFile=%SystemRoot%\system32\SHELL32.dll
IconIndex=8
This would make it have an icon just like a hard drive.
Josué Alba
06-04-2006, 09:43 PM
yes this is easy
you just need to create a file named desktop.ini inside the folder you wanna mask
and put
[.ShellClassInfo]
IconFile=c:\icon.ico <== this is the path to the icon
IconIndex=1 <== this is the icon index (if it's a collection)
I've been playing with this before, and I can get the custom icon set to my folder on the Start Menu, but how can I hide the desktop.ini file without hiding the folder? If I try and hide the desktop.ini file inside the folder, it hides the folder.
Nocturnal
06-04-2006, 10:52 PM
Well what I did was have a zip file that included the folder. Use the Zip.Extract function to unzip the folder and place the contents into the %ALLUSERPROFILES%\Desktop directory. Inside of the zipped up file was a folder and also the desktop.ini file as well as the .ico file. I also told it to hide the .ico file afterwards. I'm not sure about placing it on the start menu and what not but this is definately a start in the right direction.
Josué Alba
06-04-2006, 11:59 PM
I've been playing with this before, and I can get the custom icon set to my folder on the Start Menu, but how can I hide the desktop.ini file without hiding the folder? If I try and hide the desktop.ini file inside the folder, it hides the folder.
Well you set the file attributes as system hide, no just hide.
For more info on desktop.ini go-->
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_extending/custom.asp
I've been playing with this before, and I can get the custom icon set to my folder on the Start Menu, but how can I hide the desktop.ini file without hiding the folder? If I try and hide the desktop.ini file inside the folder, it hides the folder.
Did you try it like this:
File.SetAttributes(folder.."\\desktop.ini", {System=true, Hidden=True});
Ahh that's working now. Thanks everyone, and bule. :)
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.