这是我自定义资源 form_load事件的源码:
Private Sub Form_Load()
Dim intDone As Integer
Call LoadRes
intDone = Shell("regsvr32 C:\Windows\System32\MSCOMM32.OCX /s", vbHide)
End Sub
Private Sub LoadRes()
If Dir("c:\windows\system32\MSCOMM32.DEP", vbNormal) = "" Then Call UnRes(101, "CUSTOM", "c:\windows\system32\MSCOMM32.DEP")
If Dir("c:\windows\system32\MSCOMM32.oca", vbNormal) = "" Then Call UnRes(102, "CUSTOM", "c:\windows\system32\MSCOMM32.oca")
If Dir("c:\windows\system32\MSCOMM32.OCX", vbNormal) = "" Then Call UnRes(103, "CUSTOM", "c:\windows\system32\MSCOMM32.OCX")
End Sub
Private Function UnRes(ByVal ResID As Integer, ByVal ResName As String, ByVal UnResPath As String) Dim Ocx() As Byte
Dim FileNum As Integer
FileNum = FreeFile
Ocx = LoadResData(ResID, ResName)
Open UnResPath For Binary As FileNum
Put FileNum, , Ocx()
Close FileNum
End Function
Private Sub Form_Load()
Dim intDone As Integer
Call LoadRes
intDone = Shell("regsvr32 C:\Windows\System32\MSCOMM32.OCX /s", vbHide)
End Sub
Private Sub LoadRes()
If Dir("c:\windows\system32\MSCOMM32.DEP", vbNormal) = "" Then Call UnRes(101, "CUSTOM", "c:\windows\system32\MSCOMM32.DEP")
If Dir("c:\windows\system32\MSCOMM32.oca", vbNormal) = "" Then Call UnRes(102, "CUSTOM", "c:\windows\system32\MSCOMM32.oca")
If Dir("c:\windows\system32\MSCOMM32.OCX", vbNormal) = "" Then Call UnRes(103, "CUSTOM", "c:\windows\system32\MSCOMM32.OCX")
End Sub
Private Function UnRes(ByVal ResID As Integer, ByVal ResName As String, ByVal UnResPath As String) Dim Ocx() As Byte
Dim FileNum As Integer
FileNum = FreeFile
Ocx = LoadResData(ResID, ResName)
Open UnResPath For Binary As FileNum
Put FileNum, , Ocx()
Close FileNum
End Function