Private Declare Function LoadStandardIcon Lib "user32" Alias "LoadIconA" (ByVal _ hInstance As Long, ByVal lIconID As Long) As Long
Enum SystemIconConstants IDI_Application = 32512 IDI_Hand = 32513 IDI_Question = 32514 IDI_Exclamation = 32515 IDI_Asterisk = 32516 IDI_Windows = 32517 End Enum
Private Type PICTDESC cbSize As Long pictType As Long hIcon As Long hPal As Long End Type Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" _ (lpPictDesc As PICTDESC, riid As Any, ByVal fOwn As Long, _ ipic As IPicture) As Long
Function IconToPicture(ByVal hIcon As Long) As Picture Dim pic As PICTDESC Dim guid(0 To 3) As Long pic.cbSize = Len(pic) pic.pictType = vbPicTypeIcon pic.hIcon = hIcon guid(0) = &H7BF80980 guid(1) = &H101ABF32 guid(2) = &HAA00BB8B guid(3) = &HAB0C3000 OleCreatePictureIndirect pic, guid(0), True, IconToPicture End Function
Function GetSystemIcon(ByVal ID As SystemIconConstants) As StdPicture Set GetSystemIcon = IconToPicture(LoadStandardIcon(0, ID)) End Function |