识别VBA中的图标叠加层 [英] Identify icon overlay in VBA
问题描述
我正在寻找如何通过 Excel VBA
识别不同的图标叠加层的方法.
I'm on a quest to figure out how to identify different icon overlays through Excel VBA
.
有一个云同步软件,我试图确定我的excel文件的同步完成或仍在进行.通过跟踪某些meta(?)文件的修改日期,我能够达到基本的可靠性水平,但是没有足够的一致性来完全依赖此方法.
There is a cloud syncing software and I am trying to identify whenever the syncing of my excel file has finished or still in progress. I was able to achieve a basic level of reliability by following the modification date of some meta(?) files but there is not enough consistency to fully rely on this method.
我的搜索结果令人大吃一惊,因为 VBA
中没有关于它的太多信息.基本上,我发现每个人都使用 C ++
之类的高级语言来处理这些事情.
The result of my searches is a big punch in the face, since there is not much info about it in VBA
. Basically all I have found that everyone uses advanced languages like C++
to handle these things.
我从 VBA
中获得的最接近的源代码与系统托盘
相似,并且使用 shell32.dll
调用适当的<代码> Windows API (
The closest source I've got in VBA
does something similar with the System Tray
and uses the shell32.dll
calling the appropiate windows api
(link). But I have no idea how to make it to the Shell Icon Overlay Identifier
.
你们怎么想,有没有办法通过 VBA
做到这一点,或者我必须学习 C ++
?
What do you guys think, is there a possible way to make it through VBA
or I have to learn C++
?
推荐答案
太棒了!有可能的! SHGetFileInfo
方法有效!
它根据当前叠加层为我提供值.这是其他想要弄乱它的疯狂人的代码:
It gives me values according to the current overlays. Here is the code for any other crazy people who wanna mess around with it:
Const SHGFI_ICON = &H100
Const SHGFI_OVERLAYINDEX = &H40
Const MAX_PATH = 260
Const SYNCED = 100664316 'own specific value
Const UNDSYNC = 117442532 'own specific value
Private Type SHFILEINFO
hIcon As Long 'icon
iIcon As Long 'icon index
dwAttributes As Long 'SFGAO_ flags
szDisplayName As String * MAX_PATH 'display name (or path)
szTypeName As String * 80 'type name
End Type
Private Declare Function SHGetFileInfo Lib "shell32.dll" Alias "SHGetFileInfoA" _
(ByVal pszPath As String, _
ByVal dwFileAttributes As Long, _
psfi As SHFILEINFO, _
ByVal cbFileInfo As Long, _
ByVal uFlags As Long) As Long
Private Sub GetThatInfo()
Dim FI As SHFILEINFO
SHGetFileInfo "E:\Test.xlsm", 0, FI, Len(FI), SHGFI_ICON Or SHGFI_OVERLAYINDEX
Select Case FI.iIcon
Case SYNCED
Debug.Print "Synchronized"
Case UNDSYNC
Debug.Print "Synchronization in progress"
Case Else
Debug.Print "Some shady stuff is going on!"
End Select
End Sub
再次感谢小费!
这篇关于识别VBA中的图标叠加层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!