Design personalized folder icon with Visual Basic

xiaoxiao2021-03-06  20

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 mode: First create a Desktop.ini file in a folder that needs to be changed, as follows:

[.ShellclassInfo] confirmfileop = 0infotip = I my own folder iconindex = 0iconfile = Myfolder.ico

Explanation:

The parameter confirmfileop is set to 0 - the "You are deleting the system directory" warning from the user from moving or deleting 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.

Next open the CMD (Command Prompt), enter:

Attrib S i: / myfolder

i: / myfolder means that I have to change the path of 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 LongPrivate Sub Form_Load () 'The following steps are used to create Desktop.ini files, when there is no INI file, you will create INI WritePrivateProfileString ".shellclassInfo", "Confirmfileop", "CONFIRMFILEOP", "0", app.path & "/Desktop.ini" WritePrivateProfileString ".shellclassInfo", "Infotip", "My Folder Things Change", app.path & "/desktop.ini" WritePrivateProfileString ".shellclassInfo", "iconindex", "0" , App.path & "/desktop.ini" WritePrivateProfileString ".shellclassinfo", "iconfile", "myfolder.ico", app.path & "/desktop.ini" let folder becomes system folder PathMakesystemFolder App.Pathend Sub It is necessary to further explain:

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 0.

转载请注明原文地址:https://www.9cbs.com/read-42972.html

New Post(0)