如何降低该VB程序的CPU占用
RT。该程序详细代码如下:PrivateDeclareFunctionInitCommonControlsExLib"comctl32.dll"_(iccexAstagI...
RT。
该程序详细代码如下:
Private Declare Function InitCommonControlsEx Lib "comctl32.dll" _
(iccex As tagInitCommonControlsEx) As Boolean
Private Type tagInitCommonControlsEx
lngSize As Long
lngICC As Long
End Type
Private Const ICC_USEREX_CLASSES = &H200
Private m_hMod As Long
Private m_hMod2 As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Public Function InitCommonControlsVB() As Boolean
On Error Resume Next
Dim iccex As tagInitCommonControlsEx
With iccex
.lngSize = LenB(iccex)
.lngICC = ICC_USEREX_CLASSES
End With
InitCommonControlsEx iccex
InitCommonControlsVB = (Err.Number = 0)
On Error GoTo 0
End Function
Private Sub Form_Initialize()
InitCommonControlsVB
Dim iccex As tagInitCommonControlsEx
iccex.lngSize = LenB(iccex)
iccex.lngICC = ICC_USEREX_CLASSES
InitCommonControlsEx iccex
m_hMod = LoadLibrary("shell32.dll")
m_hMod2 = LoadLibrary("explorer.exe")
End Sub
Private Sub Form_Load()
If Command <> "" Then
WebBrowser1.Navigate Command
Else
WebBrowser1.Navigate "about:blank"
End If
End Sub
Private Sub Command1_Click()
If WebBrowser1.Width = 13780 Then
WebBrowser1.Width = 12225
Else
WebBrowser1.Width = 13780
End If
End Sub
Private Sub Command2_Click()
WebBrowser1.Navigate "http://tieba.baidu.com/f?kw=%CF%B2%D1%F2%D1%F2%D3%EB%BB%D2%CC%AB%C0%C7"
End Sub
Private Sub Command3_Click()
If Command <> "" Then
WebBrowser1.Navigate Command
Else
WebBrowser1.Navigate "about:blank"
End If
End Sub
Private Sub WebBrowser1_TitleChange(ByVal Text As String)
Dim a As String
a = Right(WebBrowser1.LocationName, 2)
If a = "奇艺" Then
Main.Caption = Replace(WebBrowser1.LocationName, "-动漫-免费高清网络视频观看-奇艺", " - 正在观看")
End If
If a = "儿台" Then
Main.Caption = Replace(WebBrowser1.LocationName, "_少儿台", " - 正在观看")
End If
End Sub
Private Sub Form_Terminate()
If m_hMod Then FreeLibrary m_hMod
If m_hMod2 Then FreeLibrary m_hMod2
End Sub
再打开程序的时候,按钮要等很久才显示。并且CPU占用率非常高,飙到100
有什么办法可以优化?
回复华仔成教:谢谢,可如何加条件呢?这个是用来实现XP风格化的。 展开
该程序详细代码如下:
Private Declare Function InitCommonControlsEx Lib "comctl32.dll" _
(iccex As tagInitCommonControlsEx) As Boolean
Private Type tagInitCommonControlsEx
lngSize As Long
lngICC As Long
End Type
Private Const ICC_USEREX_CLASSES = &H200
Private m_hMod As Long
Private m_hMod2 As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Public Function InitCommonControlsVB() As Boolean
On Error Resume Next
Dim iccex As tagInitCommonControlsEx
With iccex
.lngSize = LenB(iccex)
.lngICC = ICC_USEREX_CLASSES
End With
InitCommonControlsEx iccex
InitCommonControlsVB = (Err.Number = 0)
On Error GoTo 0
End Function
Private Sub Form_Initialize()
InitCommonControlsVB
Dim iccex As tagInitCommonControlsEx
iccex.lngSize = LenB(iccex)
iccex.lngICC = ICC_USEREX_CLASSES
InitCommonControlsEx iccex
m_hMod = LoadLibrary("shell32.dll")
m_hMod2 = LoadLibrary("explorer.exe")
End Sub
Private Sub Form_Load()
If Command <> "" Then
WebBrowser1.Navigate Command
Else
WebBrowser1.Navigate "about:blank"
End If
End Sub
Private Sub Command1_Click()
If WebBrowser1.Width = 13780 Then
WebBrowser1.Width = 12225
Else
WebBrowser1.Width = 13780
End If
End Sub
Private Sub Command2_Click()
WebBrowser1.Navigate "http://tieba.baidu.com/f?kw=%CF%B2%D1%F2%D1%F2%D3%EB%BB%D2%CC%AB%C0%C7"
End Sub
Private Sub Command3_Click()
If Command <> "" Then
WebBrowser1.Navigate Command
Else
WebBrowser1.Navigate "about:blank"
End If
End Sub
Private Sub WebBrowser1_TitleChange(ByVal Text As String)
Dim a As String
a = Right(WebBrowser1.LocationName, 2)
If a = "奇艺" Then
Main.Caption = Replace(WebBrowser1.LocationName, "-动漫-免费高清网络视频观看-奇艺", " - 正在观看")
End If
If a = "儿台" Then
Main.Caption = Replace(WebBrowser1.LocationName, "_少儿台", " - 正在观看")
End If
End Sub
Private Sub Form_Terminate()
If m_hMod Then FreeLibrary m_hMod
If m_hMod2 Then FreeLibrary m_hMod2
End Sub
再打开程序的时候,按钮要等很久才显示。并且CPU占用率非常高,飙到100
有什么办法可以优化?
回复华仔成教:谢谢,可如何加条件呢?这个是用来实现XP风格化的。 展开
2个回答
镭速传输
2024-10-28 广告
2024-10-28 广告
作为深圳市云语科技有限公司的一员,我们推出的FTP替代升级方案,旨在解决传统FTP在安全性、效率、稳定性及管理方面的不足。我们的产品通过采用自主研发的Raysync传输协议,实现高效、安全的文件传输,即使在恶劣网络环境下也能确保传输的稳定性...
点击进入详情页
本回答由镭速传输提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询