Abandon Windows's default icon, let your program you are in the directory of Folder Icon! In fact, it is very simple. In fact, you only need a Desktop.ini file, and I will explain it from two aspects.
1. Manual way:
First, create a Desktop.ini file in a folder that needs to be changed, as follows [.shellclassInfo] confirmfileop = 0infotip = I own folder iconindex = 0ICONFILE = MyFolder.ico explanation: Parameters confirmfileop is set to 0 - Prevent users Warnings for "You are deleting system Directory" that pops up when you move or delete this folder. The parameter iconfile is specified as the location of the icon file to be changed, which can be an Icon, BMP, EXE, or DLL file. The icon file in the previous example is also placed in the same directory. The parameter iconIndex can specify the index of the file. If this icon file is an icon file, IconIndex is set to 0. Parameters Infotip is used to set the tooltip in this Folder in WINDOS.
The next step opens the CMD (Command Prompt), enter Attrib S i: / myfolderi: / myfolder refers to the path I want to change the icon directory. This operation is to make your folder become a system folder.
Ok, after manual processing, the current directory has changed.
2. Programming:
This way is to be implemented with the VB I like, and the same EASY is achieved. Only two API functions are required, one for operating the establishment of the INI file, the other function is equivalent to Attrib s in the manual mode.
Option ExplicitPrivate Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As LongPrivate Declare Function PathMakeSystemFolder Lib "shlwapi.dll" Alias "PathMakeSystemFolderA" ( Byval Pszpath As String) As long
Private Sub Form_Load () 'The following steps are used to create Desktop.ini files' does not exist in INI files, create INIWRITEPRIVATEPROFILESTRING ".ShellclassInfo", "Confirmfileop", "CONFIRMFILEOP", "0", app.path & "/desktop.ini" WriteprivateProfileString ".shellclassInfo", "Infotip", "My Folder", app.path & "/desktop.ini"writeprivateprofilestring" .shellclassInfo "," iconindex "," 0 ", app.path &" / desktop.ini "WritePrivateProfileString" .ShellClassInfo "," IconFile "," MyFolder.ico ", App.Path &" /desktop.ini " 'let the files become system folder PathMakeSystemFolder App.PathEnd Sub require further noted that WritePrivateProfileString" .ShellclassInfo "," iconfile "," myfolder.ico ", app.path &" /desktop.ini "can be changed to WritePrivateProfileString" .shellclassInfo "," iConfile ", app.exename &" .exe ", app.path & "/Desktop.ini" If you use the icon of the main window, the index of the icon of the VB compiled program is also used.
This example is debugged in Win2000 and VB6