<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>VBForums - CodeBank - Visual Basic 6 and earlier</title>
		<link>http://www.vbforums.com/</link>
		<description>Find cool or practical code examples using Visual Basic.</description>
		<language>en</language>
		<lastBuildDate>Mon, 20 May 2013 12:11:03 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.vbforums.com/images/misc/rss.png</url>
			<title>VBForums - CodeBank - Visual Basic 6 and earlier</title>
			<link>http://www.vbforums.com/</link>
		</image>
		<item>
			<title>monster list codes 2</title>
			<link>http://www.vbforums.com/showthread.php?722155-monster-list-codes-2&amp;goto=newpost</link>
			<pubDate>Sun, 19 May 2013 10:59:46 GMT</pubDate>
			<description><![CDATA[Capturing audio Events


Code:
---------
Dim WithEvents Encoder As WMEncoder

Private Sub Encoder_OnStateChange(ByVal enumState As WMEncoderLib.WMENC_ENCODER_STATE)
    ' Wait until the encoding process stops before
    ' exiting the application.
    If enumState = WMENC_ENCODER_RUNNING Then
        ' TODO: Handle running state.
    ElseIf enumState = WMENC_ENCODER_PAUSED Then
        ' TODO: Handle paused state.
    ElseIf enumState = WMENC_ENCODER_STOPPED Then
        ' End the application.
        End
    Else
        ' TODO: Handle other encoder states.
    End If
End Sub

Private Sub Form_Load()
    ' Create a WMEncoder object.
    Set Encoder = New WMEncoder
  
    ' Retrieve the source group collection and add a source group.
    Dim SrcGrpColl As IWMEncSourceGroupCollection
    Set SrcGrpColl = Encoder.SourceGroupCollection
    Dim SrcGrp As IWMEncSourceGroup2
    Set SrcGrp = SrcGrpColl.Add("SG_1")
    
    ' Add a video and audio source to the source group.
    Dim SrcVid As IWMEncVideoSource2
    Dim SrcAud As IWMEncAudioSource
    Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
    Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)
    
    ' Identify the source files to encode.
    SrcVid.SetInput "C:\\InputFile.mpg"
    SrcAud.SetInput "C:\\InputFile.mpg"
    
    ' Choose a profile from the collection.
    Dim ProColl As IWMEncProfileCollection
    Dim Pro As IWMEncProfile
    Dim i As Integer
    Dim lLength As Long
    
    Set ProColl = Encoder.ProfileCollection
    lLength = ProColl.Count
    
    For i = 0 To lLength - 1
        Set Pro = ProColl.Item(i)
        If Pro.Name = "Windows Media Video 8 for Local Area Network (384 Kbps)" Then
            SrcGrp.Profile = Pro
            Exit For
        End If
    Next
    
    ' Fill in the description object members.
    Dim Descr As IWMEncDisplayInfo
    Set Descr = Encoder.DisplayInfo
    Descr.Author = "Author name"
    Descr.Copyright = "Copyright information"
    Descr.Description = "Text description of encoded content"
    Descr.Rating = "Rating information"
    Descr.Title = "Title of encoded content"
       
    ' Specify a file object in which to save encoded content.
    Dim File As IWMEncFile
    Set File = Encoder.File
    File.LocalFileName = "C:\\OutputFile.wmv"
      
    ' Start the encoding process.
    Encoder.Start
End Sub
---------

Broadcasting a Live Stream Using the Predefined UI

Code:
---------
The following example shows how to create the predefined user interface and broadcast live multimedia content from the local computer. The audio and video sources are configured to use the default sound card and capture card. Use a blank form for this example.

' Create WMEncoderApp and WMEncoder objects.
  Dim Encoder As WMEncoder
  Dim EncoderApp As WMEncoderApp

Private Sub Form_Load()
  Set EncoderApp = New WMEncoderApp
  Set Encoder = EncoderApp.Encoder

' Display the predefined Encoder UI.
  EncoderApp.Visible = True

' Specify the source for the input stream.
  Dim SrcGrpColl As IWMEncSourceGroupCollection
  Dim SrcGrp As IWMEncSourceGroup
  Dim SrcVid As IWMEncSource
  Dim SrcAud As IWMEncSource

  Set SrcGrpColl = Encoder.SourceGroupCollection
  Set SrcGrp = SrcGrpColl.Add("SG_1")
  Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
  Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

  SrcVid.SetInput "DEVICE://Default_Video_Device"
  SrcAud.SetInput "DEVICE://Default_Audio_Device"

' Specify a profile.
  Dim ProColl As IWMEncProfileCollection
  Dim Pro As IWMEncProfile
  Dim i As Integer

  Set ProColl = Encoder.ProfileCollection

  For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "Windows Media Video 8 for Local Area Network (384 Kbps)" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
  Next

' Create a broadcast.
  Dim BrdCst As IWMEncBroadcast
  Set BrdCst = Encoder.Broadcast
  BrdCst.PortNumber(WMENC_PROTOCOL_HTTP) = 8080

' Start the encoding process.
  Encoder.Start

End Sub
---------

Configuring Multiple Source Groups

Code:
---------
The following example shows how you can set up two source groups with audio and video content. The first source group uses a file (C:\InputFile.mpg), and the second source group uses the default sound card and capture card. The result is broadcasted from the local computer (http://computer_name:8080). 

For information about enumerating the audio and video devices on your system, see the Listing All Devices (Visual Basic) example.

Sub Main()
' Create a Windows Media Encoder object.
  Dim Encoder As WMEncoder
  Set Encoder = New WMEncoder
  
' Create a source group collection object from the WMEncoder object.
  Dim SrcGrpColl As IWMEncSourceGroupCollection
  Set SrcGrpColl = Encoder.SourceGroupCollection
  
' Create a profile collection object from the WMEncoder object.
  Dim ProColl As IWMEncProfileCollection
  Set ProColl = Encoder.ProfileCollection
  
' Add a source group named SG1 to the collection.
' Create a source object for each type of multimedia content
' in the source group.
  Dim SrcGrp1 As IWMEncSourceGroup2
  Dim SrcAud1 As IWMEncAudioSource
  Dim SrcVid1 As IWMEncVideoSource2
  Set SrcGrp1 = SrcGrpColl.Add("SG1")
  Set SrcAud1 = SrcGrp1.AddSource(WMENC_AUDIO)
  Set SrcVid1 = SrcGrp1.AddSource(WMENC_VIDEO)
  
' Create a second source group named SG2, and two source objects.
  Dim SrcGrp2 As IWMEncSourceGroup2
  Dim SrcAud2 As IWMEncAudioSource
  Dim SrcVid2 As IWMEncVideoSource2
  Set SrcGrp2 = SrcGrpColl.Add("SG2")
  Set SrcAud2 = SrcGrp2.AddSource(WMENC_AUDIO)
  Set SrcVid2 = SrcGrp2.AddSource(WMENC_VIDEO)
  
' Create an IWMEncBroadcast object and specify a port and a protocol.
  Dim Brdcst As IWMEncBroadcast
  Set Brdcst = Encoder.Broadcast
  Brdcst.PortNumber(WMENC_PROTOCOL_HTTP) = 8080
  
' Specify the input for the sources in the first source group.
' For this example, source group 1 uses file sources.
  SrcAud1.SetInput "C:\InputFile.mpg"
  SrcVid1.SetInput "C:\InputFile.mpg"
  
' Create a profile object. For brevity, this example uses the first
' profile in the collection. Then specify this profile object as
' the profile to use in source group 1.
  Dim Pro As IWMEncProfile
  Set Pro = ProColl.Item(0)
  SrcGrp1.Profile = Pro
  
' Specify the input sources for source group 2. In this example,
' the sources are the default audio and video devices.
' Set the profile for source group 2 to the same profile object.
  SrcAud2.SetInput "DEVICE://Default_Audio_Device"
  SrcVid2.SetInput "DEVICE://Default_Video_Device"
  SrcGrp2.Profile = Pro
  
' Set source group 1 to roll over automatically to source group 2.
' -1 indicates that the rollover happens when source group 1
' has been encoded.
  SrcGrp1.SetAutoRollover -1, "SG2"
  
' Start encoding.
  Encoder.Start

' For this example, use a message box to stop the application when you
' have finished encoding.
  MsgBox "Click OK to stop encoding."

End Sub
---------

Controlling a Digital Device (Visual Basic)


Code:
---------
Controlling a Digital Device (Visual Basic)
This example shows how to: 

Use a digital device as a source. 
Use VCR-style buttons to forward, rewind, play, and stop the tape. 
View the device output as you cue the tape before encoding. 
Use events to monitor changes in state. 
This example uses a pre-preview to display the stream before encoding begins, and a preview of the stream during encoding. 

To use this example, you need: 

A form (Form1). 
A frame (PreviewFrame). 
Four VCR-style buttons (btnREW, btnPLAY, btnFF, and btnSTOP). 
A button to start the encoding process (btnEncode). 
A label (Label1) for displaying the state of the device. 
In addition to the Windows Media Encoder reference, you must also add the Windows Media Encoder Device Control and the Windows Media Encoder Preview Control references to your project.

It is also assumed that you have a digital device connected to the computer. The Windows Media Encoder SDK supports digital video (DV) devices connected to an IEEE 1394 digital video port, and video tape recorder (VTR) devices connected through a COM port using the Sony RS422 protocol. 

Option Explicit

'Declare variables.
Dim WithEvents Encoder As WMEncoder
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup2
Dim SrcAud As IWMEncSource
Dim SrcVid As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim File As IWMEncFile
Dim DCPlugMgr As IWMEncDeviceControlPluginInfoManager
Dim PlugInfo As IWMEncPluginInfo
Dim DCColl As IWMEncDeviceControlCollection
Dim DControl As IWMEncDeviceControl
Dim DCPlugin As IWMEncDeviceControlPlugin
Dim DVColl_Preview As IWMEncDataViewCollection
Dim Preview As WMEncDataView
Dim PrePreview As WMEncPrepreview
Dim lPreviewStream As Integer
Dim sDeviceString As String
Dim i As Integer, j As Integer

Private Sub Form_Load()
' Create a WMEncoder object.
  Set Encoder = New WMEncoder

' Retrieve a device control plug-in info manager object from WMEncoder.
  Set DCPlugMgr = Encoder.DeviceControlPluginInfoManager

' Loop through the connected digital devices on the system such as DV cameras and VTRs.
  For i = 0 To DCPlugMgr.Count - 1

  ' Set the IWMEncPluginInfo object to the current plug-in.
    Set PlugInfo = DCPlugMgr.Item(i)
    
  ' Find the first device plug-in that supports resources.
    If PlugInfo.SchemeType = "DeviceControl" And PlugInfo.Resources = True Then 
        sDeviceString = PlugInfo.Item(0)
        Exit For
    End If

  Next i
  
' Add the device as the audio source and video source.
  Set SrcGrpColl = Encoder.SourceGroupCollection
  Set SrcGrp = SrcGrpColl.Add("SG_1")
  Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)
  Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
  SrcAud.SetInput ("Device://" & sDeviceString)
  SrcVid.SetInput ("Device://" & sDeviceString)

' Encode to a file.
  Set File = Encoder.File
  File.LocalFileName = "C:\DeviceOutput.wmv"
    
' Select a profile from the collection and set it into the source group.
  Set ProColl = Encoder.ProfileCollection
  For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If (Pro.Name = "Windows Media Video 8 for Local Area Network (384 Kbps)") Then
        SrcGrp.Profile = Pro
    End If
  Next i
    
' Retrieve the device control collection, then add a device to it.
  Set DCColl = SrcGrp.DeviceControlCollection
  Set DControl = DCColl.Add
  DControl.SetInput ("DeviceControl://" & sDeviceString)

  ' Initialize the encoding session.
  Encoder.PrepareToEncode True

  ' Get the plug-in from the device.
  Set DCPlugin = DControl.GetDeviceControlPlugin

  ' Get the source plug-in for the pre-preview and then display it in the frame.
  Set PrePreview = SrcVid.GetSourcePlugin
  PrePreview.SetCaptureParent PreviewFrame.hWnd

  ' Retrieve the preview collection and create a preview object.
  Set DVColl_Preview = SrcVid.PreviewCollection
  Set Preview = New WMEncDataView

End Sub
Private Sub btnEncode_Click()
  ' Specify the stream to preview.
  lPreviewStream = DVColl_Preview.Add(Preview)
  
  ' Disable the VCR buttons.
  btnREW.Enabled = False
  btnPLAY.Enabled = False
  btnFF.Enabled = False
  btnSTOP.Enabled = False
    
  ' Start encoding.
  Encoder.Start

  ' Display the preview in PreviewFrame.
  Preview.SetViewProperties lPreviewStream, PreviewFrame.hWnd
  Preview.StartView (lPreviewStream)
    
End Sub
Private Sub btnREW_Click()
  ' Rewind.
  DCPlugin.SetOperation (WMENC_DEVICE_REW)
End Sub
Private Sub btnPLAY_Click()
  ' Play.
  DCPlugin.SetOperation (WMENC_DEVICE_PLAY)
End Sub
Private Sub btnFF_Click()
  ' Forward.
  DCPlugin.SetOperation (WMENC_DEVICE_FF)
End Sub
Private Sub btnSTOP_Click()
  ' Stop.
  DCPlugin.SetOperation (WMENC_DEVICE_STOP)
End Sub

Private Sub Encoder_OnDeviceControlStateChange(ByVal EnumState As WMEncoderLib.WMENC_DEVICECONTROL_STATE, ByVal sName As String, ByVal sScheme As String)
' When the device state changes, display the state in Label1.
  Select Case EnumState:
        Case WMENC_DEVICECONTROL_PLAYING
        Label1.Caption = "Playing"
        
        Case WMENC_DEVICECONTROL_STOPPED
        Label1.Caption = "Stopped"
        
        Case WMENC_DEVICECONTROL_FASTFORWARDING
        Label1.Caption = "Forwarding"
        
        Case WMENC_DEVICECONTROL_REWINDING
        Label1.Caption = "Rewinding"
        
        Case WMENC_DEVICECONTROL_UNSTABLE
        Label1.Caption = "Unstable"
        
        Case WMENC_DEVICECONTROL_EJECT
        Label1.Caption = "Eject"
        
        Case WMENC_DEVICECONTROL_ENDOFTAPE
        Label1.Caption = "End of tape"
        bDone = True
        
    End Select
    
 End Sub
---------
]]></description>
			<content:encoded><![CDATA[<div>Capturing audio Events<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">Dim WithEvents Encoder As WMEncoder<br />
<br />
Private Sub Encoder_OnStateChange(ByVal enumState As WMEncoderLib.WMENC_ENCODER_STATE)<br />
&nbsp; &nbsp; ' Wait until the encoding process stops before<br />
&nbsp; &nbsp; ' exiting the application.<br />
&nbsp; &nbsp; If enumState = WMENC_ENCODER_RUNNING Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; ' TODO: Handle running state.<br />
&nbsp; &nbsp; ElseIf enumState = WMENC_ENCODER_PAUSED Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; ' TODO: Handle paused state.<br />
&nbsp; &nbsp; ElseIf enumState = WMENC_ENCODER_STOPPED Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; ' End the application.<br />
&nbsp; &nbsp; &nbsp; &nbsp; End<br />
&nbsp; &nbsp; Else<br />
&nbsp; &nbsp; &nbsp; &nbsp; ' TODO: Handle other encoder states.<br />
&nbsp; &nbsp; End If<br />
End Sub<br />
<br />
Private Sub Form_Load()<br />
&nbsp; &nbsp; ' Create a WMEncoder object.<br />
&nbsp; &nbsp; Set Encoder = New WMEncoder<br />
&nbsp; <br />
&nbsp; &nbsp; ' Retrieve the source group collection and add a source group.<br />
&nbsp; &nbsp; Dim SrcGrpColl As IWMEncSourceGroupCollection<br />
&nbsp; &nbsp; Set SrcGrpColl = Encoder.SourceGroupCollection<br />
&nbsp; &nbsp; Dim SrcGrp As IWMEncSourceGroup2<br />
&nbsp; &nbsp; Set SrcGrp = SrcGrpColl.Add(&quot;SG_1&quot;)<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; ' Add a video and audio source to the source group.<br />
&nbsp; &nbsp; Dim SrcVid As IWMEncVideoSource2<br />
&nbsp; &nbsp; Dim SrcAud As IWMEncAudioSource<br />
&nbsp; &nbsp; Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)<br />
&nbsp; &nbsp; Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; ' Identify the source files to encode.<br />
&nbsp; &nbsp; SrcVid.SetInput &quot;C:\\InputFile.mpg&quot;<br />
&nbsp; &nbsp; SrcAud.SetInput &quot;C:\\InputFile.mpg&quot;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; ' Choose a profile from the collection.<br />
&nbsp; &nbsp; Dim ProColl As IWMEncProfileCollection<br />
&nbsp; &nbsp; Dim Pro As IWMEncProfile<br />
&nbsp; &nbsp; Dim i As Integer<br />
&nbsp; &nbsp; Dim lLength As Long<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Set ProColl = Encoder.ProfileCollection<br />
&nbsp; &nbsp; lLength = ProColl.Count<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; For i = 0 To lLength - 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; Set Pro = ProColl.Item(i)<br />
&nbsp; &nbsp; &nbsp; &nbsp; If Pro.Name = &quot;Windows Media Video 8 for Local Area Network (384 Kbps)&quot; Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SrcGrp.Profile = Pro<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit For<br />
&nbsp; &nbsp; &nbsp; &nbsp; End If<br />
&nbsp; &nbsp; Next<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; ' Fill in the description object members.<br />
&nbsp; &nbsp; Dim Descr As IWMEncDisplayInfo<br />
&nbsp; &nbsp; Set Descr = Encoder.DisplayInfo<br />
&nbsp; &nbsp; Descr.Author = &quot;Author name&quot;<br />
&nbsp; &nbsp; Descr.Copyright = &quot;Copyright information&quot;<br />
&nbsp; &nbsp; Descr.Description = &quot;Text description of encoded content&quot;<br />
&nbsp; &nbsp; Descr.Rating = &quot;Rating information&quot;<br />
&nbsp; &nbsp; Descr.Title = &quot;Title of encoded content&quot;<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; ' Specify a file object in which to save encoded content.<br />
&nbsp; &nbsp; Dim File As IWMEncFile<br />
&nbsp; &nbsp; Set File = Encoder.File<br />
&nbsp; &nbsp; File.LocalFileName = &quot;C:\\OutputFile.wmv&quot;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; ' Start the encoding process.<br />
&nbsp; &nbsp; Encoder.Start<br />
End Sub</code><hr />
</div><br />
Broadcasting a Live Stream Using the Predefined UI<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">The following example shows how to create the predefined user interface and broadcast live multimedia content from the local computer. The audio and video sources are configured to use the default sound card and capture card. Use a blank form for this example.<br />
<br />
' Create WMEncoderApp and WMEncoder objects.<br />
&nbsp; Dim Encoder As WMEncoder<br />
&nbsp; Dim EncoderApp As WMEncoderApp<br />
<br />
Private Sub Form_Load()<br />
&nbsp; Set EncoderApp = New WMEncoderApp<br />
&nbsp; Set Encoder = EncoderApp.Encoder<br />
<br />
' Display the predefined Encoder UI.<br />
&nbsp; EncoderApp.Visible = True<br />
<br />
' Specify the source for the input stream.<br />
&nbsp; Dim SrcGrpColl As IWMEncSourceGroupCollection<br />
&nbsp; Dim SrcGrp As IWMEncSourceGroup<br />
&nbsp; Dim SrcVid As IWMEncSource<br />
&nbsp; Dim SrcAud As IWMEncSource<br />
<br />
&nbsp; Set SrcGrpColl = Encoder.SourceGroupCollection<br />
&nbsp; Set SrcGrp = SrcGrpColl.Add(&quot;SG_1&quot;)<br />
&nbsp; Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)<br />
&nbsp; Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)<br />
<br />
&nbsp; SrcVid.SetInput &quot;DEVICE://Default_Video_Device&quot;<br />
&nbsp; SrcAud.SetInput &quot;DEVICE://Default_Audio_Device&quot;<br />
<br />
' Specify a profile.<br />
&nbsp; Dim ProColl As IWMEncProfileCollection<br />
&nbsp; Dim Pro As IWMEncProfile<br />
&nbsp; Dim i As Integer<br />
<br />
&nbsp; Set ProColl = Encoder.ProfileCollection<br />
<br />
&nbsp; For i = 0 To ProColl.Count - 1<br />
&nbsp; &nbsp; Set Pro = ProColl.Item(i)<br />
&nbsp; &nbsp; If Pro.Name = &quot;Windows Media Video 8 for Local Area Network (384 Kbps)&quot; Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; SrcGrp.Profile = Pro<br />
&nbsp; &nbsp; &nbsp; &nbsp; Exit For<br />
&nbsp; &nbsp; End If<br />
&nbsp; Next<br />
<br />
' Create a broadcast.<br />
&nbsp; Dim BrdCst As IWMEncBroadcast<br />
&nbsp; Set BrdCst = Encoder.Broadcast<br />
&nbsp; BrdCst.PortNumber(WMENC_PROTOCOL_HTTP) = 8080<br />
<br />
' Start the encoding process.<br />
&nbsp; Encoder.Start<br />
<br />
End Sub</code><hr />
</div><br />
Configuring Multiple Source Groups<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">The following example shows how you can set up two source groups with audio and video content. The first source group uses a file (C:\InputFile.mpg), and the second source group uses the default sound card and capture card. The result is broadcasted from the local computer (http://computer_name:8080). <br />
<br />
For information about enumerating the audio and video devices on your system, see the Listing All Devices (Visual Basic) example.<br />
<br />
Sub Main()<br />
' Create a Windows Media Encoder object.<br />
&nbsp; Dim Encoder As WMEncoder<br />
&nbsp; Set Encoder = New WMEncoder<br />
&nbsp; <br />
' Create a source group collection object from the WMEncoder object.<br />
&nbsp; Dim SrcGrpColl As IWMEncSourceGroupCollection<br />
&nbsp; Set SrcGrpColl = Encoder.SourceGroupCollection<br />
&nbsp; <br />
' Create a profile collection object from the WMEncoder object.<br />
&nbsp; Dim ProColl As IWMEncProfileCollection<br />
&nbsp; Set ProColl = Encoder.ProfileCollection<br />
&nbsp; <br />
' Add a source group named SG1 to the collection.<br />
' Create a source object for each type of multimedia content<br />
' in the source group.<br />
&nbsp; Dim SrcGrp1 As IWMEncSourceGroup2<br />
&nbsp; Dim SrcAud1 As IWMEncAudioSource<br />
&nbsp; Dim SrcVid1 As IWMEncVideoSource2<br />
&nbsp; Set SrcGrp1 = SrcGrpColl.Add(&quot;SG1&quot;)<br />
&nbsp; Set SrcAud1 = SrcGrp1.AddSource(WMENC_AUDIO)<br />
&nbsp; Set SrcVid1 = SrcGrp1.AddSource(WMENC_VIDEO)<br />
&nbsp; <br />
' Create a second source group named SG2, and two source objects.<br />
&nbsp; Dim SrcGrp2 As IWMEncSourceGroup2<br />
&nbsp; Dim SrcAud2 As IWMEncAudioSource<br />
&nbsp; Dim SrcVid2 As IWMEncVideoSource2<br />
&nbsp; Set SrcGrp2 = SrcGrpColl.Add(&quot;SG2&quot;)<br />
&nbsp; Set SrcAud2 = SrcGrp2.AddSource(WMENC_AUDIO)<br />
&nbsp; Set SrcVid2 = SrcGrp2.AddSource(WMENC_VIDEO)<br />
&nbsp; <br />
' Create an IWMEncBroadcast object and specify a port and a protocol.<br />
&nbsp; Dim Brdcst As IWMEncBroadcast<br />
&nbsp; Set Brdcst = Encoder.Broadcast<br />
&nbsp; Brdcst.PortNumber(WMENC_PROTOCOL_HTTP) = 8080<br />
&nbsp; <br />
' Specify the input for the sources in the first source group.<br />
' For this example, source group 1 uses file sources.<br />
&nbsp; SrcAud1.SetInput &quot;C:\InputFile.mpg&quot;<br />
&nbsp; SrcVid1.SetInput &quot;C:\InputFile.mpg&quot;<br />
&nbsp; <br />
' Create a profile object. For brevity, this example uses the first<br />
' profile in the collection. Then specify this profile object as<br />
' the profile to use in source group 1.<br />
&nbsp; Dim Pro As IWMEncProfile<br />
&nbsp; Set Pro = ProColl.Item(0)<br />
&nbsp; SrcGrp1.Profile = Pro<br />
&nbsp; <br />
' Specify the input sources for source group 2. In this example,<br />
' the sources are the default audio and video devices.<br />
' Set the profile for source group 2 to the same profile object.<br />
&nbsp; SrcAud2.SetInput &quot;DEVICE://Default_Audio_Device&quot;<br />
&nbsp; SrcVid2.SetInput &quot;DEVICE://Default_Video_Device&quot;<br />
&nbsp; SrcGrp2.Profile = Pro<br />
&nbsp; <br />
' Set source group 1 to roll over automatically to source group 2.<br />
' -1 indicates that the rollover happens when source group 1<br />
' has been encoded.<br />
&nbsp; SrcGrp1.SetAutoRollover -1, &quot;SG2&quot;<br />
&nbsp; <br />
' Start encoding.<br />
&nbsp; Encoder.Start<br />
<br />
' For this example, use a message box to stop the application when you<br />
' have finished encoding.<br />
&nbsp; MsgBox &quot;Click OK to stop encoding.&quot;<br />
<br />
End Sub</code><hr />
</div><br />
Controlling a Digital Device (Visual Basic)<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">Controlling a Digital Device (Visual Basic)<br />
This example shows how to: <br />
<br />
Use a digital device as a source. <br />
Use VCR-style buttons to forward, rewind, play, and stop the tape. <br />
View the device output as you cue the tape before encoding. <br />
Use events to monitor changes in state. <br />
This example uses a pre-preview to display the stream before encoding begins, and a preview of the stream during encoding. <br />
<br />
To use this example, you need: <br />
<br />
A form (Form1). <br />
A frame (PreviewFrame). <br />
Four VCR-style buttons (btnREW, btnPLAY, btnFF, and btnSTOP). <br />
A button to start the encoding process (btnEncode). <br />
A label (Label1) for displaying the state of the device. <br />
In addition to the Windows Media Encoder reference, you must also add the Windows Media Encoder Device Control and the Windows Media Encoder Preview Control references to your project.<br />
<br />
It is also assumed that you have a digital device connected to the computer. The Windows Media Encoder SDK supports digital video (DV) devices connected to an IEEE 1394 digital video port, and video tape recorder (VTR) devices connected through a COM port using the Sony RS422 protocol. <br />
<br />
Option Explicit<br />
<br />
'Declare variables.<br />
Dim WithEvents Encoder As WMEncoder<br />
Dim SrcGrpColl As IWMEncSourceGroupCollection<br />
Dim SrcGrp As IWMEncSourceGroup2<br />
Dim SrcAud As IWMEncSource<br />
Dim SrcVid As IWMEncVideoSource<br />
Dim ProColl As IWMEncProfileCollection<br />
Dim Pro As IWMEncProfile<br />
Dim File As IWMEncFile<br />
Dim DCPlugMgr As IWMEncDeviceControlPluginInfoManager<br />
Dim PlugInfo As IWMEncPluginInfo<br />
Dim DCColl As IWMEncDeviceControlCollection<br />
Dim DControl As IWMEncDeviceControl<br />
Dim DCPlugin As IWMEncDeviceControlPlugin<br />
Dim DVColl_Preview As IWMEncDataViewCollection<br />
Dim Preview As WMEncDataView<br />
Dim PrePreview As WMEncPrepreview<br />
Dim lPreviewStream As Integer<br />
Dim sDeviceString As String<br />
Dim i As Integer, j As Integer<br />
<br />
Private Sub Form_Load()<br />
' Create a WMEncoder object.<br />
&nbsp; Set Encoder = New WMEncoder<br />
<br />
' Retrieve a device control plug-in info manager object from WMEncoder.<br />
&nbsp; Set DCPlugMgr = Encoder.DeviceControlPluginInfoManager<br />
<br />
' Loop through the connected digital devices on the system such as DV cameras and VTRs.<br />
&nbsp; For i = 0 To DCPlugMgr.Count - 1<br />
<br />
&nbsp; ' Set the IWMEncPluginInfo object to the current plug-in.<br />
&nbsp; &nbsp; Set PlugInfo = DCPlugMgr.Item(i)<br />
&nbsp; &nbsp; <br />
&nbsp; ' Find the first device plug-in that supports resources.<br />
&nbsp; &nbsp; If PlugInfo.SchemeType = &quot;DeviceControl&quot; And PlugInfo.Resources = True Then <br />
&nbsp; &nbsp; &nbsp; &nbsp; sDeviceString = PlugInfo.Item(0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; Exit For<br />
&nbsp; &nbsp; End If<br />
<br />
&nbsp; Next i<br />
&nbsp; <br />
' Add the device as the audio source and video source.<br />
&nbsp; Set SrcGrpColl = Encoder.SourceGroupCollection<br />
&nbsp; Set SrcGrp = SrcGrpColl.Add(&quot;SG_1&quot;)<br />
&nbsp; Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)<br />
&nbsp; Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)<br />
&nbsp; SrcAud.SetInput (&quot;Device://&quot; &amp; sDeviceString)<br />
&nbsp; SrcVid.SetInput (&quot;Device://&quot; &amp; sDeviceString)<br />
<br />
' Encode to a file.<br />
&nbsp; Set File = Encoder.File<br />
&nbsp; File.LocalFileName = &quot;C:\DeviceOutput.wmv&quot;<br />
&nbsp; &nbsp; <br />
' Select a profile from the collection and set it into the source group.<br />
&nbsp; Set ProColl = Encoder.ProfileCollection<br />
&nbsp; For i = 0 To ProColl.Count - 1<br />
&nbsp; &nbsp; Set Pro = ProColl.Item(i)<br />
&nbsp; &nbsp; If (Pro.Name = &quot;Windows Media Video 8 for Local Area Network (384 Kbps)&quot;) Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; SrcGrp.Profile = Pro<br />
&nbsp; &nbsp; End If<br />
&nbsp; Next i<br />
&nbsp; &nbsp; <br />
' Retrieve the device control collection, then add a device to it.<br />
&nbsp; Set DCColl = SrcGrp.DeviceControlCollection<br />
&nbsp; Set DControl = DCColl.Add<br />
&nbsp; DControl.SetInput (&quot;DeviceControl://&quot; &amp; sDeviceString)<br />
<br />
&nbsp; ' Initialize the encoding session.<br />
&nbsp; Encoder.PrepareToEncode True<br />
<br />
&nbsp; ' Get the plug-in from the device.<br />
&nbsp; Set DCPlugin = DControl.GetDeviceControlPlugin<br />
<br />
&nbsp; ' Get the source plug-in for the pre-preview and then display it in the frame.<br />
&nbsp; Set PrePreview = SrcVid.GetSourcePlugin<br />
&nbsp; PrePreview.SetCaptureParent PreviewFrame.hWnd<br />
<br />
&nbsp; ' Retrieve the preview collection and create a preview object.<br />
&nbsp; Set DVColl_Preview = SrcVid.PreviewCollection<br />
&nbsp; Set Preview = New WMEncDataView<br />
<br />
End Sub<br />
Private Sub btnEncode_Click()<br />
&nbsp; ' Specify the stream to preview.<br />
&nbsp; lPreviewStream = DVColl_Preview.Add(Preview)<br />
&nbsp; <br />
&nbsp; ' Disable the VCR buttons.<br />
&nbsp; btnREW.Enabled = False<br />
&nbsp; btnPLAY.Enabled = False<br />
&nbsp; btnFF.Enabled = False<br />
&nbsp; btnSTOP.Enabled = False<br />
&nbsp; &nbsp; <br />
&nbsp; ' Start encoding.<br />
&nbsp; Encoder.Start<br />
<br />
&nbsp; ' Display the preview in PreviewFrame.<br />
&nbsp; Preview.SetViewProperties lPreviewStream, PreviewFrame.hWnd<br />
&nbsp; Preview.StartView (lPreviewStream)<br />
&nbsp; &nbsp; <br />
End Sub<br />
Private Sub btnREW_Click()<br />
&nbsp; ' Rewind.<br />
&nbsp; DCPlugin.SetOperation (WMENC_DEVICE_REW)<br />
End Sub<br />
Private Sub btnPLAY_Click()<br />
&nbsp; ' Play.<br />
&nbsp; DCPlugin.SetOperation (WMENC_DEVICE_PLAY)<br />
End Sub<br />
Private Sub btnFF_Click()<br />
&nbsp; ' Forward.<br />
&nbsp; DCPlugin.SetOperation (WMENC_DEVICE_FF)<br />
End Sub<br />
Private Sub btnSTOP_Click()<br />
&nbsp; ' Stop.<br />
&nbsp; DCPlugin.SetOperation (WMENC_DEVICE_STOP)<br />
End Sub<br />
<br />
Private Sub Encoder_OnDeviceControlStateChange(ByVal EnumState As WMEncoderLib.WMENC_DEVICECONTROL_STATE, ByVal sName As String, ByVal sScheme As String)<br />
' When the device state changes, display the state in Label1.<br />
&nbsp; Select Case EnumState:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Case WMENC_DEVICECONTROL_PLAYING<br />
&nbsp; &nbsp; &nbsp; &nbsp; Label1.Caption = &quot;Playing&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Case WMENC_DEVICECONTROL_STOPPED<br />
&nbsp; &nbsp; &nbsp; &nbsp; Label1.Caption = &quot;Stopped&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Case WMENC_DEVICECONTROL_FASTFORWARDING<br />
&nbsp; &nbsp; &nbsp; &nbsp; Label1.Caption = &quot;Forwarding&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Case WMENC_DEVICECONTROL_REWINDING<br />
&nbsp; &nbsp; &nbsp; &nbsp; Label1.Caption = &quot;Rewinding&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Case WMENC_DEVICECONTROL_UNSTABLE<br />
&nbsp; &nbsp; &nbsp; &nbsp; Label1.Caption = &quot;Unstable&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Case WMENC_DEVICECONTROL_EJECT<br />
&nbsp; &nbsp; &nbsp; &nbsp; Label1.Caption = &quot;Eject&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Case WMENC_DEVICECONTROL_ENDOFTAPE<br />
&nbsp; &nbsp; &nbsp; &nbsp; Label1.Caption = &quot;End of tape&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; bDone = True<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; End Select<br />
&nbsp; &nbsp; <br />
&nbsp;End Sub</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?43-CodeBank-Visual-Basic-6-and-earlier">CodeBank - Visual Basic 6 and earlier</category>
			<dc:creator>ladoo</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?722155-monster-list-codes-2</guid>
		</item>
		<item>
			<title>VB - LED simulator Simulating a LED light emitting diode</title>
			<link>http://www.vbforums.com/showthread.php?722025-VB-LED-simulator-Simulating-a-LED-light-emitting-diode&amp;goto=newpost</link>
			<pubDate>Fri, 17 May 2013 18:04:10 GMT</pubDate>
			<description><![CDATA[Interesting way to present a process monitor, servers, control aplications ON/OFF, electronic kits etc.
Simulating a LED light emitting diode, add sound may be an improvement ...

I hear comments
Greetings from Mexico

UPDATED from "LED simulator.zip" (beta) to "LED simulator 1.0"
improved with help from *4x2y* really thanks]]></description>
			<content:encoded><![CDATA[<div>Interesting way to present a process monitor, servers, control aplications ON/OFF, electronic kits etc.<br />
Simulating a LED light emitting diode, add sound may be an improvement ...<br />
<br />
I hear comments<br />
Greetings from Mexico<br />
<br />
UPDATED from &quot;LED simulator.zip&quot; (beta) to &quot;LED simulator 1.0&quot;<br />
improved with help from <b>4x2y</b> really thanks</div>


	<div style="padding:10px">

	

	

	

	
		<fieldset class="fieldset">
			<legend>Attached Files</legend>
			<ul>
			<li>
	<img class="inlineimg" src="http://www.vbforums.com/images/attach/zip.gif" alt="File Type: zip" />
	<a href="http://www.vbforums.com/attachment.php?attachmentid=100261&amp;d=1368813776">LED simulator.zip</a> 
(1.8 KB)
</li><li>
	<img class="inlineimg" src="http://www.vbforums.com/images/attach/zip.gif" alt="File Type: zip" />
	<a href="http://www.vbforums.com/attachment.php?attachmentid=100287&amp;d=1368860011">LED simulator 1.0.zip</a> 
(1.6 KB)
</li>
			</ul>
		</fieldset>
	

	</div>
]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?43-CodeBank-Visual-Basic-6-and-earlier">CodeBank - Visual Basic 6 and earlier</category>
			<dc:creator>phoner</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?722025-VB-LED-simulator-Simulating-a-LED-light-emitting-diode</guid>
		</item>
		<item>
			<title>create ocx tutorial</title>
			<link>http://www.vbforums.com/showthread.php?721919-create-ocx-tutorial&amp;goto=newpost</link>
			<pubDate>Thu, 16 May 2013 17:25:04 GMT</pubDate>
			<description>step by step with image and code

http://cuinl.tripod.com/tutorials/ocx-11.htm</description>
			<content:encoded><![CDATA[<div>step by step with image and code<br />
<br />
<a rel="nofollow" href="http://cuinl.tripod.com/tutorials/ocx-11.htm" target="_blank">http://cuinl.tripod.com/tutorials/ocx-11.htm</a></div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?43-CodeBank-Visual-Basic-6-and-earlier">CodeBank - Visual Basic 6 and earlier</category>
			<dc:creator>ladoo</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?721919-create-ocx-tutorial</guid>
		</item>
		<item>
			<title>VB6 Crypto API</title>
			<link>http://www.vbforums.com/showthread.php?721703-VB6-Crypto-API&amp;goto=newpost</link>
			<pubDate>Wed, 15 May 2013 06:48:06 GMT</pubDate>
			<description>I cannot take credit for the cCrypt.cls used here, but I ran across it while searching for information on implementing TLS using the MS Crypto API. Unfortunately it did not help me with TLS, and I could not find who to give credit, but I was impressed with the quality of the code in the way that it encompassed most of the supported algorithms in the API. I am more interested in limited cryptography targeted to the TLS handshake, and I am having a great deal of difficulty finding relative information.

J.A. Coutts</description>
			<content:encoded><![CDATA[<div>I cannot take credit for the cCrypt.cls used here, but I ran across it while searching for information on implementing TLS using the MS Crypto API. Unfortunately it did not help me with TLS, and I could not find who to give credit, but I was impressed with the quality of the code in the way that it encompassed most of the supported algorithms in the API. I am more interested in limited cryptography targeted to the TLS handshake, and I am having a great deal of difficulty finding relative information.<br />
<br />
J.A. Coutts</div>


	<div style="padding:10px">

	

	

	

	
		<fieldset class="fieldset">
			<legend>Attached Files</legend>
			<ul>
			<li>
	<img class="inlineimg" src="http://www.vbforums.com/images/attach/zip.gif" alt="File Type: zip" />
	<a href="http://www.vbforums.com/attachment.php?attachmentid=100151&amp;d=1368600440">cCrypt.zip</a> 
(11.4 KB)
</li>
			</ul>
		</fieldset>
	

	</div>
]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?43-CodeBank-Visual-Basic-6-and-earlier">CodeBank - Visual Basic 6 and earlier</category>
			<dc:creator>couttsj</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?721703-VB6-Crypto-API</guid>
		</item>
		<item>
			<title>Very Cheap Text/Voice Chat Application</title>
			<link>http://www.vbforums.com/showthread.php?721557-Very-Cheap-Text-Voice-Chat-Application&amp;goto=newpost</link>
			<pubDate>Tue, 14 May 2013 02:36:52 GMT</pubDate>
			<description>This application allows you to text chat or voice chat using two client applications</description>
			<content:encoded><![CDATA[<div>This application allows you to text chat or voice chat using two client applications</div>


	<div style="padding:10px">

	

	

	

	
		<fieldset class="fieldset">
			<legend>Attached Files</legend>
			<ul>
			<li>
	<img class="inlineimg" src="http://www.vbforums.com/images/attach/zip.gif" alt="File Type: zip" />
	<a href="http://www.vbforums.com/attachment.php?attachmentid=100071&amp;d=1368498966">A Very Cheap Text_Voice Chat App.zip</a> 
(17.4 KB)
</li>
			</ul>
		</fieldset>
	

	</div>
]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?43-CodeBank-Visual-Basic-6-and-earlier">CodeBank - Visual Basic 6 and earlier</category>
			<dc:creator>jmsrickland</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?721557-Very-Cheap-Text-Voice-Chat-Application</guid>
		</item>
		<item>
			<title><![CDATA[[VB6] HotKeyW - Unicode Hot Key UserControl]]></title>
			<link>http://www.vbforums.com/showthread.php?721315-VB6-HotKeyW-Unicode-Hot-Key-UserControl&amp;goto=newpost</link>
			<pubDate>Sat, 11 May 2013 20:37:19 GMT</pubDate>
			<description><![CDATA[A simple and lightweight Hot Key UserControl that "enables the user to enter a combination of keystrokes to be used as a hot key". This is a drop-in ready UserControl module that wraps the Hot Key (http://msdn.microsoft.com/en-us/library/bb775234%28v=vs.85%29.aspx) control from Windows' Common Controls Library.


Attachment 99975 (http://www.vbforums.com/attachment.php?attachmentid=99975)
]]></description>
			<content:encoded><![CDATA[<div>A simple and lightweight Hot Key UserControl that <i>&quot;enables the user to enter a combination of keystrokes to be used as a hot key&quot;</i>. This is a drop-in ready UserControl module that wraps the <a rel="nofollow" href="http://msdn.microsoft.com/en-us/library/bb775234%28v=vs.85%29.aspx" target="_blank">Hot Key</a> control from Windows' Common Controls Library.<br />
<br />
<br />
<div style="text-align: center;"><img src="http://www.vbforums.com/attachment.php?attachmentid=99975&amp;d=1368304249" border="0" alt="Name:  Screenshot.png
Views: 55
Size:  18.3 KB"  /></div></div>


	<div style="padding:10px">

	

	
		<fieldset class="fieldset">
			<legend>Attached Images</legend>
				<div style="padding:10px">
				<img class="attach" src="http://www.vbforums.com/attachment.php?attachmentid=99975&amp;stc=1&amp;d=1368304249" alt="" />&nbsp;
			</div>
		</fieldset>
	

	

	
		<fieldset class="fieldset">
			<legend>Attached Files</legend>
			<ul>
			<li>
	<img class="inlineimg" src="http://www.vbforums.com/images/attach/zip.gif" alt="File Type: zip" />
	<a href="http://www.vbforums.com/attachment.php?attachmentid=99977&amp;d=1368304749">HotKeyW.zip</a> 
(15.9 KB)
</li>
			</ul>
		</fieldset>
	

	</div>
]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?43-CodeBank-Visual-Basic-6-and-earlier">CodeBank - Visual Basic 6 and earlier</category>
			<dc:creator>Bonnie West</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?721315-VB6-HotKeyW-Unicode-Hot-Key-UserControl</guid>
		</item>
		<item>
			<title><![CDATA[VB6 - Zipper & ZipWriter, Zipping from VB programs]]></title>
			<link>http://www.vbforums.com/showthread.php?720251-VB6-Zipper-amp-ZipWriter-Zipping-from-VB-programs&amp;goto=newpost</link>
			<pubDate>Thu, 02 May 2013 17:55:15 GMT</pubDate>
			<description><![CDATA[*Background*

A lot of us find the need to create ZIP archives programmatically from time to time.  There are a number of techniques we can use, from spawning external utility programs to 3rd party components to Shell automation.

Here is yet another way to accomplish this: using the free, open source zlibwapi.dll


*Minizip*

In addition to providing a STDCALL version of ZLib that we can call easily from VB6 programs zlibwapi.dll includes the Minizip project code as well.

Like a lot of open source hacked out by C coders this can be rough in many places, but it is widely used and well proven.  It should have few if any bugs in the most recent version.

I'm using version 1.25 here.  You can get this from:

Minizip: Zip and UnZip additionnal library (http://www.winimage.com/zLibDll/minizip.html)

See the typo there?  This is just one symptom of some of the issues, but fortunately the code at least seems to work fine even if its source is wonky with lots of flaws in comments and general documentation issues.

This DLL is not included in the attachment.  You must download it yourself.


---Quote---
In zlib125dll.zip there is the Win32 Windows DLL of my Windows DLL named Zlibwapi.dll that contains both zLib and Minilib.
---End Quote---
The file you want from this ZIP archive is:

zlib125dll.zip\dll32\zlibwapi.dll


*ZipWriter*

ZipWriter is a VB6 Class that wraps zlibwapi.dll to provide you with a way to create a ZIP archive and actually write data into it as archived files with no intermediate disk I/O steps.

You can use this as-is in many cases without the other code offered here.


*Zipper*

Zipper is a VB6 UserControl that wraps ZipWriter and a small helper ZipFile Class to give you the ability to create a ZIP archive (or add to an existing one) and add a list of disk files to it.

Zipper.Zip is an async operation and reports back progress, errors, and completion through several events.  There is a Zipper.Cancel method if you need that.


*ZipDemo*

ZipDemo is a VB6 project that demonstrates use of the items described above.

You must download zlibwapi.dll and copy it into this project folder to run the program.

Much of the bulk of this attachment consists of the sample files in the "samples2" folder included.


There is a "ZipWriter" button that does a simple test of ZipWriter, creating a new ZIP archive "test.zip" with two files written to it.  When that step completes the "Zipper" button is enabled.

The "Zipper" button tests Zipper, adding the files it finds in the "samples2" folder to the "test.zip" created in the first stage of the demo.  While running a progressbar is updated and a "Cancel" button is enabled.

The "samples2" folder as supplied has just a few small files.  Be sure to copy some larger files into it and rerun the program to see how things go with large files.  The performance is fairly good.


*Remarks*

While you need to deploy zlibwapi.dll with your programs this is a standard DLL that you can feel free to place next to your EXE.  No registration is required.

The results are better than those achieved using most other common techniques.  Progress/Cancel/Complete can be really nice to have.  There is no need for the shaky, convoluted, hackish window spelunking people often resort to when automating Shell objects.

There is a lot more you can do with zlibwapi.dll too.  You can read from ZIP archives, unzip them, compress separate files outside of ZIP archives, compress/expand data in memory, etc.  Even the huge-file Zip64 format is supported.

All you need is to write additional wrappers or just make the calls directly.]]></description>
			<content:encoded><![CDATA[<div><b>Background</b><br />
<br />
A lot of us find the need to create ZIP archives programmatically from time to time.  There are a number of techniques we can use, from spawning external utility programs to 3rd party components to Shell automation.<br />
<br />
Here is yet another way to accomplish this: using the free, open source zlibwapi.dll<br />
<br />
<br />
<b>Minizip</b><br />
<br />
In addition to providing a STDCALL version of ZLib that we can call easily from VB6 programs zlibwapi.dll includes the Minizip project code as well.<br />
<br />
Like a lot of open source hacked out by C coders this can be rough in many places, but it is widely used and well proven.  It should have few if any bugs in the most recent version.<br />
<br />
I'm using version 1.25 here.  You can get this from:<br />
<br />
<a rel="nofollow" href="http://www.winimage.com/zLibDll/minizip.html" target="_blank">Minizip: Zip and UnZip additionnal library</a><br />
<br />
See the typo there?  This is just one symptom of some of the issues, but fortunately the code at least seems to work fine even if its source is wonky with lots of flaws in comments and general documentation issues.<br />
<br />
<i>This DLL is not included in the attachment.</i>  You must download it yourself.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Quote:</div>
	<div class="bbcode_quote printable">
		<hr />
		
			In zlib125dll.zip there is the Win32 Windows DLL of my Windows DLL named Zlibwapi.dll that contains both zLib and Minilib.
			
		<hr />
	</div>
</div>The file you want from this ZIP archive is:<br />
<br />
<tt>zlib125dll.zip\dll32\zlibwapi.dll</tt><br />
<br />
<br />
<b>ZipWriter</b><br />
<br />
ZipWriter is a VB6 Class that wraps zlibwapi.dll to provide you with a way to create a ZIP archive and actually write data into it as archived files with no intermediate disk I/O steps.<br />
<br />
You can use this as-is in many cases without the other code offered here.<br />
<br />
<br />
<b>Zipper</b><br />
<br />
Zipper is a VB6 UserControl that wraps ZipWriter and a small helper ZipFile Class to give you the ability to create a ZIP archive (or add to an existing one) and add a list of disk files to it.<br />
<br />
Zipper.Zip is an async operation and reports back progress, errors, and completion through several events.  There is a Zipper.Cancel method if you need that.<br />
<br />
<br />
<b>ZipDemo</b><br />
<br />
ZipDemo is a VB6 project that demonstrates use of the items described above.<br />
<br />
<i>You must download zlibwapi.dll and copy it into this project folder to run the program.</i><br />
<br />
Much of the bulk of this attachment consists of the sample files in the &quot;samples2&quot; folder included.<br />
<br />
<br />
There is a &quot;ZipWriter&quot; button that does a simple test of ZipWriter, creating a new ZIP archive &quot;test.zip&quot; with two files written to it.  When that step completes the &quot;Zipper&quot; button is enabled.<br />
<br />
The &quot;Zipper&quot; button tests Zipper, adding the files it finds in the &quot;samples2&quot; folder to the &quot;test.zip&quot; created in the first stage of the demo.  While running a progressbar is updated and a &quot;Cancel&quot; button is enabled.<br />
<br />
The &quot;samples2&quot; folder as supplied has just a few small files.  Be sure to copy some larger files into it and rerun the program to see how things go with large files.  The performance is fairly good.<br />
<br />
<br />
<b>Remarks</b><br />
<br />
While you need to deploy zlibwapi.dll with your programs this is a standard DLL that you can feel free to place next to your EXE.  No registration is required.<br />
<br />
The results are better than those achieved using most other common techniques.  Progress/Cancel/Complete can be really nice to have.  There is no need for the shaky, convoluted, hackish window spelunking people often resort to when automating Shell objects.<br />
<br />
There is a lot more you can do with zlibwapi.dll too.  You can read from ZIP archives, unzip them, compress separate files outside of ZIP archives, compress/expand data in memory, etc.  Even the huge-file Zip64 format is supported.<br />
<br />
All you need is to write additional wrappers or just make the calls directly.</div>


	<div style="padding:10px">

	

	

	

	
		<fieldset class="fieldset">
			<legend>Attached Files</legend>
			<ul>
			<li>
	<img class="inlineimg" src="http://www.vbforums.com/images/attach/zip.gif" alt="File Type: zip" />
	<a href="http://www.vbforums.com/attachment.php?attachmentid=99717&amp;d=1367516772">Zipper.zip</a> 
(33.8 KB)
</li>
			</ul>
		</fieldset>
	

	</div>
]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?43-CodeBank-Visual-Basic-6-and-earlier">CodeBank - Visual Basic 6 and earlier</category>
			<dc:creator>dilettante</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?720251-VB6-Zipper-amp-ZipWriter-Zipping-from-VB-programs</guid>
		</item>
	</channel>
</rss>
