VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form FMain
BorderStyle = 1 'Fixed Single
Caption = "Release Dll Demo"
ClientHeight = 1935
ClientLeft = 45
ClientTop = 330
ClientWidth = 4680
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1935
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin MSComDlg.CommonDialog cd
Left = 780
Top = 900
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton cmdFile
Caption = "..."
Height = 315
Left = 4260
TabIndex = 2
Top = 315
Width = 315
End
Begin VB.TextBox txtFile
Height = 315
Left = 165
TabIndex = 1
Top = 315
Width = 4080
End
Begin VB.CommandButton cmdRelease
Caption = "&Release Dll"
Height = 315
Left = 645
TabIndex = 0
Top = 1455
Width = 3225
End
End
Attribute VB_Name = "FMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdFile_Click()
Dim sFile As String
With cd
.Filter = "*.dll|*.dll;*.*|*.*"
.ShowSave
sFile = .FileName
End With
If Len(sFile) > 0 Then txtFile.Text = sFile: txtFile.SelStart = Len(sFile)
End Sub
Private Sub cmdRelease_Click()
Dim abDll() As Byte, lCount As Long, lFile As Long, sFile As String
sFile = txtFile.Text
If Len(sFile) < 1 Then MsgBox "Please input output file name!": Exit Sub
abDll = LoadResData("Balloon", "DLL")
lCount = UBound(abDll)
lFile = FreeFile
On Error GoTo ErrRow
Open sFile For Binary Access Write As lFile
Put #lFile, , abDll
Close lFile
Do While Dir(sFile) = "": Loop
MsgBox "File released!"
Shell "regsvr32 " & """" & sFile & """"
GoTo EndRow
ErrRow:
MsgBox Err.Description
EndRow: