呵呵~~~~~偶会,可是分数少了点!如:
Private sub Form_Load()
set me.icon=loadpicture("c:\i256.ico")
end subPrivate command1_click()
Dim nMainhwnd&,hIcon&
shell "notepad.exe",1
nmainhwnd=findwindow("NotePad",vbnullstring)
hicon=sendmessage(me.hwnd,WM_GETICON,ICON_BIG,byval 0)
sendmessage nMainhwnd,WM_SETICON,ICON_BIG,byval hicon
end sub
Private sub Form_Load()
set me.icon=loadpicture("c:\i256.ico")
end subPrivate command1_click()
Dim nMainhwnd&,hIcon&
shell "notepad.exe",1
nmainhwnd=findwindow("NotePad",vbnullstring)
hicon=sendmessage(me.hwnd,WM_GETICON,ICON_BIG,byval 0)
sendmessage nMainhwnd,WM_SETICON,ICON_BIG,byval hicon
end sub
好一点的办法是读取另一个程序的ICON到内存变量或PICTUREBOX,然后使窗体的ICON等于它
Private Sub Form_Load()
'Me.Icon = LoadPicture("c:\windows\ebetween0.ico")
End SubPrivate Sub Command1_click()
Dim nMainhwnd&, hIcon&
nMainhwnd& = FindWindow(vbNullString, "无标题 - 记事本")
If nMainhwnd& = 0 Then
Shell "notepad.exe", 1
hIcon = SendMessage(Me.hwnd, WM_GETICON, ICON_BIG, ByVal 0)
SendMessage nMainhwnd, WM_SETICON, ICON_BIG, ByVal hIcon
Else
hIcon = SendMessage(Me.hwnd, WM_GETICON, ICON_BIG, ByVal 0)
SendMessage nMainhwnd, WM_SETICON, ICON_BIG, ByVal hIcon
End If
End Sub'BAS 声名
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPublic Const WM_GETICON = &H7F
Public Const WM_SETICON = &H80
Public Const ICON_SMALL = 0
Public Const ICON_BIG = 1
Option Explicit
Const SHGFI_SMALLICON = &H1
Const SHGFI_SYSICONINDEX = &H4000
Const SHGFI_DISPLAYNAME = &H200
Const SHGFI_TYPENAME = &H400
Const MAX_PATH = 260
Const WM_SETICON = &H80
Const ICON_BIG = 1
Const SHGFI_LARGEICON = &H0
Const ICON_SMALL = 0
Const SHGFI_ICON = &H100Private Type SHFILEINFO
hIcon As Long
iIcon As Long
dwAttributes As Long
szDisplayName As String * MAX_PATH
szTypeName As String * 80
End Type
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate 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 LongPrivate Sub Form_Load()
Dim Rt&
'DeityFox 2001
'URL: http://www.dimsun.com/
'E-Mail: [email protected]
Dim FI As SHFILEINFO
Rt = SHGetFileInfo("c:\winnt\notepad.exe", 0, FI, Len(FI), SHGFI_ICON Or SHGFI_SYSICONINDEX Or SHGFI_TYPENAME)
SendMessage Me.hwnd, WM_SETICON, 1, ByVal FI.hIcon
End Sub哈哈,行了吗?