есть такая недокументированная функция SHChangeIconDialog.
может кто знает как из нее пользу извлечь? т.е. по прямому назначению использовать, а то она не возвращает ни файл, ни номер иконки
Private Declare Function SHChangeIconDialog Lib "Shell32" Alias "#62" (ByVal hOwner As Long, ByVal szFilename As String, Reserved As Long, lpIconIndex As Long) As Long
Private Const VER_PLATFORM_WIN32_NT = 2
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFO) As Long
Private Declare Function SHChangeIconDialogA Lib "shell32" Alias "#62" (ByVal hOwner As Long, ByVal szFilename As String, ByVal Reserved As Long, lpIconIndex As Long) As Long
Private Declare Function SHChangeIconDialogW Lib "shell32" Alias "#62" (ByVal hOwner As Long, ByVal szFilename As Long, ByVal Reserved As Long, lpIconIndex As Long) As Long
'Detect if the program is running under Windows NT
Public Function IsWinNT() As Boolean
Dim myOS As OSVERSIONINFO
myOS.dwOSVersionInfoSize = Len(myOS)
GetVersionEx myOS
IsWinNT = (myOS.dwPlatformId = VER_PLATFORM_WIN32_NT)
End Function
Public Function chooseIcon(ByRef strFile As String, ByRef lngIconNum As Long) As Boolean
Dim str1 As String * 260
Dim lng1 As Long ' Dummy?
Dim lngResult As Long
str1 = strFile & vbNullChar
'is this code executed under WinNT?
If IsWinNT Then
'if we're in WinNT, we have to call the Unicode version of the function
lngResult = SHChangeIconDialogW(Me.hWnd, StrPtr(str1), lng1, lngIconNum)
Else
'if we're in Win9x, we have to call the ANSI version of the function
lngResult = SHChangeIconDialogA(Me.hWnd, str1, lng1, lngIconNum)
End If
'The function itself returns 0 (failed) or 1 (success)
'str1 is adapted to the selected filename
chooseIcon = (lngResult <> 0)
If chooseIcon Then
strFile = Left$(str1, InStr(1, str1, vbNullChar, vbBinaryCompare) - 1)
End If
End Function
Private Sub Form_Load()
Dim IconFile As String
Dim IconIndex As Long
IconFile = "shell32.dll"
IconIndex = 0
chooseIcon IconFile, IconIndex
Me.AutoRedraw = True
Me.Print IconFile & "," & IconIndex
End Sub
Сейчас этот форум просматривают: AhrefsBot, Majestic-12 [Bot], Yandex-бот и гости: 118