vb调用shell32.dll的图标
在VB中如何调用shell32.dll中的系统图标为自己的图标,例如运行程序后随机生成个数字,当数字为1时,程序图标变为和windows文件夹图标一样,为2时变为和win...
在VB中如何调用shell32.dll中的系统图标为自己的图标,例如运行程序后随机生成个数字,当数字为1时,程序图标变为和windows文件夹图标一样,为2时变为和windows其他EXE文件图标一样的那个白框
最好有源码发我E-mail:7899706@qq.com 展开
最好有源码发我E-mail:7899706@qq.com 展开
1个回答
展开全部
帮你改到直接应用到窗口了,加分把
给你完整代码如下:
Option Explicit
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Function SetIcon(hWnd As Long, Optional FileName As String, Optional IconIndex As Integer) As Long
Dim hIcon As Long
hIcon = ExtractIcon(GetModuleHandle(FileName), FileName, IconIndex)
SetIcon = SendMessage(hWnd, &H80, 0, ByVal hIcon)
End Function
Private Sub Form_Load()
SetIcon Me.hWnd, "c:\windows\system32\shell32.dll", 0
End Sub
给你完整代码如下:
Option Explicit
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Function SetIcon(hWnd As Long, Optional FileName As String, Optional IconIndex As Integer) As Long
Dim hIcon As Long
hIcon = ExtractIcon(GetModuleHandle(FileName), FileName, IconIndex)
SetIcon = SendMessage(hWnd, &H80, 0, ByVal hIcon)
End Function
Private Sub Form_Load()
SetIcon Me.hWnd, "c:\windows\system32\shell32.dll", 0
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询