VB personalized folder icon

Source: Internet
Author: User

Discard the default icon of windows to make the directory of your program have a personalized folder icon!
In fact, it is very simple. In fact, you only need a desktop. ini file. I will explain it in two aspects.

1. manual mode:

First, create a desktop. ini file in the folder to be changed. The example is as follows:
[. Shellclassinfo]
Confirmfileop = 0
Infotip = my own folder
Iconindex = 0
Iconfile = myfolder. ICO
Explanation:
The confirmfileop parameter is set to 0, which prevents the warning "you are deleting the system directory" from pop-up when you move or delete this folder.
The parameter iconfile is specified as the location of the icon file to be changed. It can be an icon, BMP, EXE, or DLL file. The icon file in the above example is also placed in the same directory.
The iconindex parameter specifies the file index. If the icon file is an icon file, the iconindex is set to 0.
The infotip parameter is used to set the tooltip of this folder in windows.

Next, open cmd (command prompt) and enter
Attrib + s I: \ myfolder
I: \ myfolder refers to the path of the directory to which I want to change the graph. This operation makes your folder a system folder.

Now the directory style has changed after manual processing.

2. Programming Method:

This method is implemented using my favorite VB, which is also easy to implement.
Only two API functions are required. One is used to create an INI file, and the other is equivalent to attrib + S in the manual mode.

Option explicit
Private declare function writeprivateprofilestring lib "Kernel32" alias "writeprivateprofilestringa" (byval lpapplicationname as string, byval lpkeyname as any, byval lpstring as any, byval lpfilename as string) as long
Private declare function pathmakesystemfolder lib "shlwapi. dll" alias "pathmakesystemfoldera" (byval pszpath as string) as long

Private sub form_load ()
'Use the following steps to create a desktop. ini file:
'If the INI file does not exist, the INI file is created by yourself.
Writeprivateprofilestring ". shellclassinfo", "confirmfileop", "0", app. Path & "\ desktop. ini"
Writeprivateprofilestring ". shellclassinfo", "infotip", "my folder changes accordingly", app. Path & "\ desktop. ini"
Writeprivateprofilestring ". shellclassinfo", "iconindex", "0", app. Path & "\ desktop. ini"
Writeprivateprofilestring ". shellclassinfo", "iconfile", "myfolder. ICO", app. Path & "\ desktop. ini"
'Make the folder a system folder
Pathmakesystemfolder app. Path
End sub

It should be 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 are using the icon of the main window, the index of the icon of the program compiled by VB is also 0.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.