Hi
Thanks for your reply.
If you don't understand these two documents very well, I can give you two examples. You can refer to the following two methods. You can choose one of them to try. You can also refer to this link.
1. Manual:
First create a Desktop.ini file in the folder that needs to be changed, for example:
[.ShellClassInfo]
ConfirmFileOp=0
InfoTip=my folder
IconIndex=0
IconFile=MyFolder.ico
explain:
parameter ConfirmFileOp set 0--Prevents the "You are deleting the system directory" warning that pops up when users move or delete this folder.
parameter IconFile Specify the location of the icon file to be changed, which can be an Icon, Bmp, exe or dll file. The icon file in the above example is also placed in the same directory.
parameter IconIndex You can specify the index of the file. If the icon file is an Icon file, IconIndex is set to 0.
parameter InfoTip Used to set the Tooltip of this Folder in Windows.
Next step open CMD (Command Prompt) and enter:
attrib +s i:\MyFolder
i:\MyFolder It refers to the path of the directory where I want to change the icon. This action makes your folder a system folder.
2. programmatically:
Need VBA
Only two API functions are needed, one is used to manipulate the creation of Ini files, 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()
'The following steps are used to create the Desktop.ini file
'If the ini file does not exist, it will create the ini by itself
WritePrivateProfileString ".ShellClassInfo", "ConfirmFileOp", "0", App.Path & "\desktop.ini"
WritePrivateProfileString ".ShellClassInfo", "InfoTip", "my folder changed because of this", App.Path & "\desktop.ini"
WritePrivateProfileString ".ShellClassInfo", "IconIndex", "0", App.Path & "\desktop.ini"
WritePrivateProfileString ".ShellClassInfo", "IconFile", "MyFolder.ico", App.Path & "\desktop.ini"
Best regards
Derrick Qian | Microsoft Community Support Specialist
-----------------------
* Beware of scammers posting fake support numbers here.
* Please check and vote this answer if it helps as it will be beneficial to more community members reading here.