<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Source Code VB</title>
	<atom:link href="http://programmervb.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmervb.wordpress.com</link>
	<description>Source Code VB and Tutorial</description>
	<pubDate>Sat, 19 Jul 2008 04:54:39 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
	<language>en</language>
			<item>
		<title>Network Monitor</title>
		<link>http://programmervb.wordpress.com/2008/07/19/network-monitor-2/</link>
		<comments>http://programmervb.wordpress.com/2008/07/19/network-monitor-2/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 04:54:39 +0000</pubDate>
		<dc:creator>programmervb</dc:creator>
		
		<category><![CDATA[Source Code]]></category>

		<category><![CDATA[Network Monitor]]></category>

		<guid isPermaLink="false">http://programmervb.wordpress.com/?p=112</guid>
		<description><![CDATA[Option Explicit
Const SYNCHRONIZE = &#38;H100000
Const INFINITE = &#38;HFFFF
Const WAIT_OBJECT_0 = 0
Const WAIT_TIMEOUT = &#38;H102
Dim stopflag As Boolean
Dim errorflag As Boolean
Dim mindelay As Integer
Dim maxdelay As Integer
Dim totaldelay As Long
Dim avgdelay As Integer
Dim lcount As Long
Dim pingMessage(26) As String
Dim ctrl
Private Declare Function SendMessage Lib &#8220;User32&#8243; Alias &#8220;SendMessageA&#8221; (ByVal hWnd As Long, ByVal wMsg As Long, ByVal [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Option Explicit</p>
<p>Const SYNCHRONIZE = &amp;H100000<br />
Const INFINITE = &amp;HFFFF<br />
Const WAIT_OBJECT_0 = 0<br />
Const WAIT_TIMEOUT = &amp;H102</p>
<p>Dim stopflag As Boolean<br />
Dim errorflag As Boolean</p>
<p>Dim mindelay As Integer<br />
Dim maxdelay As Integer<br />
Dim totaldelay As Long<br />
Dim avgdelay As Integer<br />
Dim lcount As Long<br />
Dim pingMessage(26) As String<br />
Dim ctrl<br />
Private Declare Function SendMessage Lib &#8220;User32&#8243; Alias &#8220;SendMessageA&#8221; (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long<br />
Private Declare Function OpenProcess Lib &#8220;kernel32&#8243; (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long<br />
Private Declare Function WaitForSingleObject Lib &#8220;kernel32&#8243; (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long<br />
Private Declare Function CloseHandle Lib &#8220;kernel32&#8243; (ByVal hObject As Long) As Long</p>
<p>Private Sub cmdClear_Click()<br />
    Open &#8220;C:\log.txt&#8221; For Output As #1<br />
    Close #1<br />
    txtoutput.Text = &#8220;&#8221;<br />
    txtpinglog.Text = &#8220;&#8221;<br />
End Sub</p>
<p>Private Sub cmdExit_Click()<br />
    Unload Me<br />
    End<br />
End Sub</p>
<p>Private Sub cmdlog_Click()<br />
    Load frmlog<br />
    frmlog.Show 1<br />
End Sub</p>
<p>Private Sub cmdPing_Click()<br />
DoEvents<br />
If cmdPing.Caption = &#8220;Ping&#8221; Then<br />
    lblstatus.Caption = &#8220;Pinging &#8221; &amp; txtIP.Text &amp; &#8221; with &#8221; &amp; txtbuffer.Text &amp; &#8220;KB of data&#8221;<br />
    txtIP.Locked = True<br />
    cmdPing.BackColor = &amp;HFF&amp;<br />
   cmdlog.Enabled = False<br />
    cmdPing.Caption = &#8220;Stop&#8221;<br />
    stopflag = False<br />
Else<br />
    stopflag = True<br />
   cmdPing.Caption = &#8220;Ping&#8221;<br />
   txtIP.Locked = False<br />
   cmdPing.BackColor = &amp;H80FF80<br />
   cmdlog.Enabled = True<br />
   lblstatus.Caption = &#8220;Stopped&#8221;<br />
End If<br />
   <br />
While stopflag = False<br />
  DoEvents<br />
        <br />
    Dim ShellX As String<br />
    Dim lPid As Long<br />
    Dim lHnd As Long<br />
    Dim lRet As Long<br />
    Dim VarX As String<br />
    Dim Ptime As Integer<br />
    Dim pttl As Integer<br />
    Dim pbyte As Integer<br />
    Dim i As Integer<br />
    Dim pingresult As String<br />
    Dim tmin As Integer<br />
    Dim tmax As Integer<br />
    Dim tavg As Integer<br />
   <br />
      If txtIP.Text &lt;&gt; &#8220;&#8221; Then<br />
        DoEvents<br />
        ShellX = Shell(&#8221;command.com /c ping -n 1 -l &#8221; &amp; txtbuffer.Text &amp; &#8221; &#8221; &amp; txtIP.Text &amp; &#8221; &gt; C:\log.txt&#8221;, vbHide)<br />
        lPid = ShellX<br />
        If lPid &lt;&gt; 0 Then<br />
            lHnd = OpenProcess(SYNCHRONIZE, 0, lPid)<br />
            If lHnd &lt;&gt; 0 Then<br />
                lRet = WaitForSingleObject(lHnd, INFINITE)<br />
                CloseHandle (lHnd)<br />
            End If<br />
               <br />
                frmmain.MousePointer = 0<br />
                Open &#8220;C:\log.txt&#8221; For Input As #1<br />
                txtoutput.Text = Input(LOF(1), 1)<br />
               <br />
                pingresult = Trim(Mid(txtoutput.Text, InStr(1, txtoutput.Text, &#8220;:&#8221;) + 1, Len(txtoutput.Text) - (InStr(1, txtoutput.Text, &#8220;:&#8221;) + Len(Mid(txtoutput.Text, InStr(1, txtoutput.Text, &#8220;Ping &#8220;))))))<br />
               <br />
                &#8216;check for error<br />
                If InStr(1, pingresult, &#8220;Reply&#8221;) = 0 Then<br />
                     Dim message As String<br />
                    If InStr(1, pingresult, &#8220;Hardware&#8221;) &lt;&gt; 0 Then<br />
                              message = &#8220;HARDWARE FAULT&#8221;<br />
                         Else<br />
                            If InStr(1, pingresult, &#8220;Request&#8221;) &lt;&gt; 0 Then<br />
                              message = &#8220;Request time out&#8221;<br />
                         Else<br />
                              If InStr(1, pingresult, &#8220;Destination&#8221;) &lt;&gt; 0 Then<br />
                                   message = &#8220;Destination Computer is not reachable&#8221;<br />
                              Else<br />
                                   message = pingresult<br />
                                End If<br />
                       <br />
                        End If<br />
                    End If<br />
                   pingresult = &#8220;ERROR with &#8221; &amp; txtIP.Text &amp; &#8220;:&#8221; &amp; message<br />
                          <br />
                 <br />
                   &#8216;pingmessage<br />
                  txtpinglog.Text = &#8220;&#8221;<br />
                  For i = 0 To 22<br />
                        pingMessage(i) = pingMessage(i + 1)<br />
                       If pingMessage(i + 1) &lt;&gt; &#8220;&#8221; Then<br />
                                If txtpinglog.Text &lt;&gt; &#8220;&#8221; Then<br />
                                    txtpinglog.Text = txtpinglog.Text &amp; vbCrLf<br />
                                End If<br />
                                    txtpinglog.Text = txtpinglog.Text &amp; pingMessage(i + 1)<br />
                        End If<br />
                   Next<br />
                  <br />
                   pingMessage(23) = pingresult<br />
                   If txtpinglog.Text &lt;&gt; &#8220;&#8221; Then<br />
                                txtpinglog.Text = txtpinglog.Text &amp; vbCrLf<br />
                    End If<br />
                   txtpinglog.Text = txtpinglog.Text &amp; pingresult</p>
<p>                      For i = 0 To 31<br />
                            pbrtime(i).Value = pbrtime(i + 1).Value<br />
                         Next<br />
                         pbrtime(32).Value = 0<br />
                        <br />
                       <br />
                        <br />
                         &#8216;loging<br />
                            If chklog.Value = 1 Then<br />
                                If errorflag = False Then<br />
                                    errorflag = True<br />
                                        Open &#8220;c:\pinglog.txt&#8221; For Append As #2<br />
                                            Print #2, Now<br />
                                            Print #2, pingresult<br />
                                            Print #2, String(91, &#8220;*&#8221;)<br />
                                        Close #2<br />
                                End If<br />
                            End If<br />
                               lcount = 0<br />
                               mindelay = 0<br />
                               maxdelay = 0<br />
                               avgdelay = 0<br />
                               totaldelay = 0<br />
                              <br />
                                lblmin = mindelay<br />
                                lblmax = maxdelay<br />
                                lblavg = avgdelay<br />
                        <br />
                 Else<br />
                   lcount = lcount + 1<br />
                    Ptime = CInt(Mid(txtoutput.Text, InStr(1, txtoutput.Text, &#8220;time&#8221;) + 5, InStr(1, txtoutput.Text, &#8220;ms &#8220;) - InStr(1, txtoutput.Text, &#8220;time&#8221;) - 5))<br />
                    pbyte = CInt(Mid(txtoutput.Text, InStr(1, txtoutput.Text, &#8220;bytes=&#8221;) + 6, InStr(1, txtoutput.Text, &#8221; time&#8221;) - InStr(1, txtoutput.Text, &#8220;bytes=&#8221;) - 6))<br />
                    pttl = CInt(Mid(pingresult, InStr(1, pingresult, &#8220;TTL=&#8221;) + 4, Len(pingresult) - InStr(1, pingresult, &#8220;TTL=&#8221;) - 5))<br />
                   <br />
                    tmin = CInt(Mid(txtoutput.Text, InStr(1, txtoutput.Text, &#8220;Minimum = &#8220;) + 10, InStr(InStr(1, txtoutput.Text, &#8220;Minimum = &#8220;), txtoutput.Text, &#8220;ms,&#8221;) - InStr(1, txtoutput.Text, &#8220;Minimum = &#8220;) - 10))<br />
                    tmax = CInt(Mid(txtoutput.Text, InStr(1, txtoutput.Text, &#8220;Maximum = &#8220;) + 10, InStr(InStr(1, txtoutput.Text, &#8220;Maximum = &#8220;), txtoutput.Text, &#8220;ms,&#8221;) - InStr(1, txtoutput.Text, &#8220;Maximum = &#8220;) - 10))<br />
                    tavg = CInt(Mid(txtoutput.Text, InStr(1, txtoutput.Text, &#8220;Average = &#8220;) + 10, InStr(InStr(1, txtoutput.Text, &#8220;Average = &#8220;), txtoutput.Text, &#8220;ms&#8221;) - InStr(1, txtoutput.Text, &#8220;Average = &#8220;) - 10))<br />
                   <br />
                    If mindelay = 0 Then mindelay = tmin<br />
                   <br />
                    If tmin &lt; mindelay Then<br />
                        mindelay = tmin<br />
                    End If<br />
                    If tmax &gt; maxdelay Then<br />
                        maxdelay = tmax<br />
                    End If<br />
                    totaldelay = totaldelay + tavg<br />
                    avgdelay = CInt(totaldelay / lcount)<br />
                   <br />
                    lblmin = mindelay<br />
                    lblmax = maxdelay<br />
                    lblavg = avgdelay<br />
                   <br />
                If avgdelay &gt; 0 Then<br />
                    For Each ctrl In frmmain<br />
                        If TypeOf ctrl Is ProgressBar Then<br />
                            ctrl.Max = avgdelay * 10<br />
                        End If<br />
                    Next<br />
                End If<br />
                       <br />
                   <br />
                   <br />
                pingresult = &#8220;Reply from &#8221; &amp; txtIP.Text &amp; &#8220;: bytes=&#8221; &amp; pbyte &amp; &#8221; time=&#8221; &amp; Ptime &amp; &#8220;ms TTL=&#8221; &amp; pttl<br />
                txtpinglog.Text = &#8220;&#8221;<br />
                  For i = 0 To 22<br />
                        pingMessage(i) = pingMessage(i + 1)<br />
                        If pingMessage(i + 1) &lt;&gt; &#8220;&#8221; Then<br />
                            If txtpinglog.Text &lt;&gt; &#8220;&#8221; Then<br />
                                txtpinglog.Text = txtpinglog.Text &amp; vbCrLf<br />
                            End If<br />
                            txtpinglog.Text = txtpinglog.Text &amp; pingMessage(i + 1)<br />
                        End If<br />
                   Next<br />
                   pingMessage(23) = pingresult<br />
                    If txtpinglog.Text &lt;&gt; &#8220;&#8221; Then<br />
                        txtpinglog.Text = txtpinglog.Text &amp; vbCrLf<br />
                    End If<br />
                   txtpinglog.Text = txtpinglog.Text &amp; pingresult<br />
                                 <br />
                      <br />
                      <br />
                       &#8216;loging<br />
                        If chklog.Value = 1 Then<br />
                                If errorflag = True Then<br />
                                    errorflag = False<br />
                                        Open &#8220;c:\pinglog.txt&#8221; For Append As #2<br />
                                            Print #2, Now<br />
                                            Print #2, &#8220;Reconnected with &#8221; &amp; txtIP.Text<br />
                                            Print #2, String(91, &#8220;*&#8221;)<br />
                                        Close #2<br />
                                End If<br />
                            End If<br />
                           <br />
                           <br />
                         On Error Resume Next<br />
                            Ptime = CInt(Mid(txtoutput.Text, InStr(1, txtoutput.Text, &#8220;time=&#8221;) + 5, InStr(1, txtoutput.Text, &#8220;ms &#8220;) - InStr(1, txtoutput.Text, &#8220;time=&#8221;) - 5))<br />
                         For i = 0 To 31<br />
                            pbrtime(i).Value = pbrtime(i + 1).Value<br />
                         Next<br />
                         pbrtime(32).Value = Ptime<br />
                    <br />
                End If<br />
                       Close #1<br />
        End If<br />
      Else<br />
        frmmain.MousePointer = 0<br />
        VarX = MsgBox(&#8221;You have not entered an ip address or the number of times you want to ping.&#8221;, vbCritical, &#8220;Error has occured&#8221;)<br />
      End If<br />
Wend<br />
End Sub</p>
<p>Private Sub Command1_Click()<br />
Load frmAbout<br />
frmAbout.Show 1<br />
End Sub</p>
<p>Private Sub Form_Load()</p>
<p>errorflag = False<br />
totaldelay = 0<br />
mindelay = 0<br />
maxdelay = 0<br />
avgdelay = 0<br />
lcount = 0<br />
  Open &#8220;C:\log.txt&#8221; For Output As #1<br />
  Close #1<br />
End Sub</p>
<p>Private Sub SelectText(ByRef textObj As RichTextBox)<br />
    textObj.SelStart = 0<br />
    textObj.SelLength = Len(textObj)<br />
End Sub</p>
<p>Private Sub Label6_Click()</p>
<p>End Sub</p>
<p>Private Sub Form_Unload(Cancel As Integer)<br />
End<br />
End Sub</p>
<p>Private Sub Label2_Click()</p>
<p>End Sub</p>
<p>Private Sub Slider1_Change()<br />
Select Case Slider1.Value<br />
Case 0: txtbuffer.Text = 32<br />
Case 1: txtbuffer.Text = 320<br />
Case 2: txtbuffer.Text = 3200<br />
Case 3: txtbuffer.Text = 32000</p>
<p>End Select<br />
       <br />
        lcount = 0<br />
        mindelay = 0<br />
        maxdelay = 0<br />
        avgdelay = 0<br />
        totaldelay = 0<br />
       <br />
         lblmin = mindelay<br />
         lblmax = maxdelay<br />
         lblavg = avgdelay<br />
       <br />
End Sub</p>
<p>Private Sub Timer1_Timer()<br />
End Sub</p>
<p>Private Sub txtIP_GotFocus()<br />
    Call SelectText(txtIP)<br />
End Sub<br />
Private Sub txtOutput_GotFocus()<br />
&#8216;    Call SelectText(txtoutput)<br />
End Sub</p>
<p>Private Sub txtStatus_Click()<br />
    txtIP.SetFocus<br />
End Sub</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/programmervb.wordpress.com/112/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/programmervb.wordpress.com/112/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmervb.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmervb.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmervb.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmervb.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmervb.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmervb.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmervb.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmervb.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmervb.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmervb.wordpress.com/112/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmervb.wordpress.com&blog=3238720&post=112&subd=programmervb&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://programmervb.wordpress.com/2008/07/19/network-monitor-2/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/programmervb-128.jpg" medium="image">
			<media:title type="html">Ed</media:title>
		</media:content>
	</item>
		<item>
		<title>Net User Information and Security Using ActiveDS Type Library</title>
		<link>http://programmervb.wordpress.com/2008/07/15/net-user-information-and-security-using-activeds-type-library/</link>
		<comments>http://programmervb.wordpress.com/2008/07/15/net-user-information-and-security-using-activeds-type-library/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 14:37:56 +0000</pubDate>
		<dc:creator>programmervb</dc:creator>
		
		<category><![CDATA[Source Code]]></category>

		<category><![CDATA[Net User Information and Security Using ActiveDS Type L]]></category>

		<guid isPermaLink="false">http://programmervb.wordpress.com/?p=110</guid>
		<description><![CDATA[Public Function IsGroupMember(Username As String, _
DomainName As String, _
GroupName As String) As Boolean
&#8216;=================================================
&#8216;=================================================
&#8216;   Purpose:    To determin if a user is a member of a specified group
&#8216;
&#8216;   Syntax:     IsGroupMember(User Name, Domain Name, Group Name)
&#8216;
&#8216;   Arguments:
&#8216;               username        &#8212; login ID of user to verify
&#8216;               DomainName      &#8212; Domain name the user and group reside in
&#8216;                (Can also use [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Public Function IsGroupMember(Username As String, _<br />
DomainName As String, _<br />
GroupName As String) As Boolean<br />
&#8216;=================================================<br />
&#8216;=================================================<br />
&#8216;   Purpose:    To determin if a user is a member of a specified group<br />
&#8216;<br />
&#8216;   Syntax:     IsGroupMember(User Name, Domain Name, Group Name)<br />
&#8216;<br />
&#8216;   Arguments:<br />
&#8216;               username        &#8212; login ID of user to verify<br />
&#8216;               DomainName      &#8212; Domain name the user and group reside in<br />
&#8216;                (Can also use IP Address of Primary Domain Controller)<br />
&#8216;               GroupName       &#8212; NT Group name to match the user to<br />
&#8216;<br />
&#8216;   Example:    IsGroupMember(&#8221;myusername&#8221;, &#8220;mydomain&#8221;, &#8220;mygroupname&#8221;)<br />
&#8216;==========================================================<br />
&#8216;==========================================================<br />
Dim usr As IADsUser, obj As Object, sOut() As String, i As Long<br />
IsGroupMember = False<br />
Set usr = GetObject(&#8221;WinNT://&#8221; &amp; DomainName &amp; &#8220;/&#8221; &amp; Username &amp; &#8220;,user&#8221;)<br />
For Each obj In usr.Groups<br />
If GroupName = obj.Name Then IsGroupMember = True<br />
Next<br />
End Function</p>
<p>Function IsGoodPWD(sUserName As String, DomainName As String, _<br />
chkPassword As String) As Boolean<br />
&#8216;====================================================<br />
&#8216;=====================================================<br />
&#8216;   Purpose:    To determin if a password given is the correct network password for the specified user<br />
&#8216;<br />
&#8216;   Syntax:     IsGoodPWD(User Name, Domain Name, Password)<br />
&#8216;<br />
&#8216;   Arguments:<br />
&#8216;               username        &#8212; login ID of user to verify<br />
&#8216;               DomainName      &#8212; Domain name the user and group reside in<br />
&#8216;                           (Can also use IP Address of Primary Domain Controller)<br />
&#8216;               chkPassword     &#8212; Password to verify against the domain<br />
&#8216;<br />
&#8216;   Example:    IsGoodPWD(&#8221;myusername&#8221;, &#8220;mydomain&#8221;, &#8220;mypass123&#8243;)<br />
&#8216;==============================================================<br />
&#8216;=========================================================<br />
On Error GoTo MyError:<br />
Dim usr As IADsUser<br />
Set usr = GetObject(&#8221;WinNT://&#8221; &amp; DomainName &amp; &#8220;/&#8221; &amp; sUserName &amp; &#8220;,user&#8221;)<br />
usr.ChangePassword chkPassword, &#8220;qinspwue4&#8243;<br />
usr.ChangePassword &#8220;qinspwue4&#8243;, chkPassword<br />
IsGoodPWD = True<br />
Exit Function<br />
MyError:<br />
IsGoodPWD = False<br />
End Function</p>
<p>Public Function ShowGroupMembers(DomainName As String, _<br />
UserGroupName As String)<br />
&#8216;=========================================================<br />
&#8216;=========================================================<br />
&#8216;   Purpose:    To display the members of a specified user group<br />
&#8216;<br />
&#8216;   Syntax:     ShowGroupMembers(Domain Name, User Group Name)<br />
&#8216;<br />
&#8216;   Arguments:<br />
&#8216;               DomainName      &#8212; Domain name the user and group reside in<br />
&#8216;                            (Can also use IP Address of Primary Domain Controller)<br />
&#8216;               UserGroupName   &#8212; The name of the NT User Group<br />
&#8216;<br />
&#8216;   Example:    Call ShowGroupMembers(&#8221;mydomain&#8221;, &#8220;mygroupname&#8221;)<br />
&#8216;============================================================<br />
&#8216;============================================================<br />
Dim grp As IADsGroup, User As Object<br />
Set grp = GetObject(&#8221;WinNT://&#8221; &amp; DomainName &amp; &#8220;/&#8221; &amp; UserGroupName &amp; &#8220;&#8221;)<br />
For Each User In grp.members<br />
Debug.Print User.Name<br />
Next User<br />
End Function</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/programmervb.wordpress.com/110/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/programmervb.wordpress.com/110/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmervb.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmervb.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmervb.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmervb.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmervb.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmervb.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmervb.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmervb.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmervb.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmervb.wordpress.com/110/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmervb.wordpress.com&blog=3238720&post=110&subd=programmervb&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://programmervb.wordpress.com/2008/07/15/net-user-information-and-security-using-activeds-type-library/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/programmervb-128.jpg" medium="image">
			<media:title type="html">Ed</media:title>
		</media:content>
	</item>
		<item>
		<title>File Size</title>
		<link>http://programmervb.wordpress.com/2008/07/15/file-size/</link>
		<comments>http://programmervb.wordpress.com/2008/07/15/file-size/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 14:32:54 +0000</pubDate>
		<dc:creator>programmervb</dc:creator>
		
		<category><![CDATA[Source Code]]></category>

		<category><![CDATA[File Size]]></category>

		<guid isPermaLink="false">http://programmervb.wordpress.com/?p=108</guid>
		<description><![CDATA[Private Sub cmdShowFileSize_Click()
Dim strOldFile As String
Dim strOldSize As String
Dim strMyDir As String
Dim strMyFile As String
strMyDir = &#8220;c:\windows\desktop&#8221;
strMyFile = &#8220;readme.txt&#8221;
strOldFile = strMyDir &#38; &#8220;\&#8221; &#38; strMyFile
strOldSize = FileLen(strOldFile)
lblFileSize.Caption = &#8220;The file &#8221; &#38; strOldFile &#38; &#8221; is &#8221; &#38; _
Format(strOldSize, &#8220;#,##0&#8243;) &#38; &#8221; bytes in size.&#8221;
End Sub
       ]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Private Sub cmdShowFileSize_Click()<br />
Dim strOldFile As String<br />
Dim strOldSize As String<br />
Dim strMyDir As String<br />
Dim strMyFile As String</p>
<p>strMyDir = &#8220;c:\windows\desktop&#8221;<br />
strMyFile = &#8220;readme.txt&#8221;</p>
<p>strOldFile = strMyDir &amp; &#8220;\&#8221; &amp; strMyFile<br />
strOldSize = FileLen(strOldFile)</p>
<p>lblFileSize.Caption = &#8220;The file &#8221; &amp; strOldFile &amp; &#8221; is &#8221; &amp; _<br />
Format(strOldSize, &#8220;#,##0&#8243;) &amp; &#8221; bytes in size.&#8221;</p>
<p>End Sub</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/programmervb.wordpress.com/108/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/programmervb.wordpress.com/108/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmervb.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmervb.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmervb.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmervb.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmervb.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmervb.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmervb.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmervb.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmervb.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmervb.wordpress.com/108/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmervb.wordpress.com&blog=3238720&post=108&subd=programmervb&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://programmervb.wordpress.com/2008/07/15/file-size/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/programmervb-128.jpg" medium="image">
			<media:title type="html">Ed</media:title>
		</media:content>
	</item>
		<item>
		<title>Animation 21</title>
		<link>http://programmervb.wordpress.com/2008/07/14/animation-21/</link>
		<comments>http://programmervb.wordpress.com/2008/07/14/animation-21/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 14:25:54 +0000</pubDate>
		<dc:creator>programmervb</dc:creator>
		
		<category><![CDATA[Source Code]]></category>

		<category><![CDATA[Animation 21]]></category>

		<guid isPermaLink="false">http://programmervb.wordpress.com/?p=106</guid>
		<description><![CDATA[&#8216;5 picture boxs, 1 timer, 2 labels and 1 button
Option Explicit
Private Declare Function BitBlt Lib &#8220;gdi32&#8243; (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Const SRCCOPY [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>&#8216;5 picture boxs, 1 timer, 2 labels and 1 button</p>
<p>Option Explicit<br />
Private Declare Function BitBlt Lib &#8220;gdi32&#8243; (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long<br />
Const SRCCOPY = &amp;HCC0020<br />
Const SRCAND = &amp;H8800C6<br />
Const SRCPAINT = &amp;HEE0086<br />
Dim SpriteX&amp; &#8216; dim a long variable to hold the current X position on the Cave Dude sprite</p>
<p>Private Sub Command1_Click()</p>
<p>If Not Timer1.Enabled Then      &#8216; jika timer mati<br />
Timer1.Enabled = True       &#8216; fungsi timer aktif<br />
Command1.Caption = &#8220;Stop!&#8221;   &#8216; tombol command berubah -&gt;&#8217;STOP&#8217;<br />
Else<br />
Timer1.Enabled = False      &#8216; jika timer hidup<br />
Command1.Caption = &#8220;Go!&#8221;     &#8216; tombol command berubah -&gt;&#8217;Lanjut&#8217;<br />
End If</p>
<p>End Sub</p>
<p>Private Sub Form_Load()</p>
<p>Dim ReturnResult&amp; &#8216;dim a long variable to hold the return value BitBlt will pass<br />
SpriteX&amp; = 512 &#8216; set the starting X coordinate for the Cave Dude sprite<br />
ReturnResult&amp; = BitBlt(picOldDisplay.hDC, 0, 0, 64, 64, picDisplay.hDC, SpriteX&amp;, 64, SRCCOPY) &#8216; copy a &#8220;clean&#8221; area from the display to be repainted when the loops comes around again to get rid of the old player X blit</p>
<p>End Sub</p>
<p>Private Sub Timer1_Timer()</p>
<p>Static AnimationCount&amp; &#8216; dim a long variable to hold which animation frame we are on, and make it static, so it retains its&#8217; value between procedures<br />
Dim ReturnResult&amp; &#8216;dim a long variable to hold the return value BitBlt will pass</p>
<p>ReturnResult = BitBlt(picDisplay.hDC, SpriteX&amp;, 64, 64, 64, picOldDisplay.hDC, 0, 0, SRCCOPY) &#8216; copy the clean part of the display back over the old sprite X<br />
SpriteX&amp; = SpriteX&amp; - 5 &#8216;the cave dude walks from right to left, so he starts out at a positive X location, and we decrement his location every loops by 5 pixels<br />
ReturnResult = BitBlt(picOldDisplay.hDC, 0, 0, 64, 64, picDisplay.hDC, SpriteX&amp;, 64, SRCCOPY) &#8216; copy a &#8220;clean&#8221; area from the display to be repainted when the loops comes around again to get rid of the old player X blit<br />
picOldDisplay.Refresh &#8216; refresh the old display to reflect changes (this is only done to show what the contents of this picturebox look like. Normally this picturebox would not be visible to the player)<br />
ReturnResult&amp; = BitBlt(picWorkArea.hDC, 0, 0, 64, 64, picOldDisplay.hDC, 0, 0, SRCCOPY) &#8216; copy the area the sprite will be blitted to into the work area<br />
ReturnResult&amp; = BitBlt(picWorkArea.hDC, 0, 0, 64, 64, picCaveDudeMask.hDC, AnimationCount&amp;, 0, SRCAND) &#8216; SRCAND the sprite mask on top of the display section we copied<br />
ReturnResult&amp; = BitBlt(picWorkArea.hDC, 0, 0, 64, 64, picCaveDude.hDC, AnimationCount&amp;, 0, SRCPAINT) &#8216; SRCPAINT the sprite on top of the mask and the display section<br />
picWorkArea.Refresh &#8216; refresh the work area to reflect changes(this is only done to show what the contents of this picturebox look like. Normally this picturebox would not be visible to the player)<br />
ReturnResult&amp; = BitBlt(picDisplay.hDC, SpriteX&amp;, 64, 64, 64, picWorkArea.hDC, 0, 0, SRCCOPY) &#8216; SRCCOPY the completed display section with transparent sprite back into the display picturebox<br />
picDisplay.Refresh &#8216; refresh the display to reflect the changes</p>
<p>If SpriteX&amp; &lt; -64 Then  &#8216; if the Cave Dude walks off the screen completely, reset the program, and start him walking again<br />
SpriteX&amp; = 512<br />
AnimationCount&amp; = 0<br />
picOldDisplay.Cls<br />
picWorkArea.Cls<br />
ReturnResult&amp; = BitBlt(picOldDisplay.hDC, 0, 0, 64, 64, picDisplay.hDC, SpriteX&amp;, 64, SRCCOPY) &#8216; copy a &#8220;clean&#8221; area from the display to be repainted when the loops comes around again to get rid of the old player X blit<br />
End If</p>
<p>AnimationCount&amp; = AnimationCount&amp; + 64 &#8216; increment the animation by one frame</p>
<p>If AnimationCount&amp; = 512 Then AnimationCount&amp; = 0 &#8216; if the AnimationCount is equal to the number of animation frames we have, reset the frame count to 0 to start over</p>
<p>End Sub</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/programmervb.wordpress.com/106/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/programmervb.wordpress.com/106/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmervb.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmervb.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmervb.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmervb.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmervb.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmervb.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmervb.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmervb.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmervb.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmervb.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmervb.wordpress.com&blog=3238720&post=106&subd=programmervb&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://programmervb.wordpress.com/2008/07/14/animation-21/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/programmervb-128.jpg" medium="image">
			<media:title type="html">Ed</media:title>
		</media:content>
	</item>
		<item>
		<title>Knife Animation</title>
		<link>http://programmervb.wordpress.com/2008/07/14/knife-animation/</link>
		<comments>http://programmervb.wordpress.com/2008/07/14/knife-animation/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 14:24:18 +0000</pubDate>
		<dc:creator>programmervb</dc:creator>
		
		<category><![CDATA[Source Code]]></category>

		<category><![CDATA[Knife Animation]]></category>

		<guid isPermaLink="false">http://programmervb.wordpress.com/?p=104</guid>
		<description><![CDATA[Dim FrameCount As Long
Private Sub Command1_Click()
Timer1.Enabled = False
If LoadGif(Text1, Image1) Then
FrameCount = 0
Timer1.Interval = CLng(Image1(0).Tag)
Timer1.Enabled = True
End If
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Command3_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Text1.Text = App.Path &#38; IIf(Right(App.Path, 1) = &#8220;\&#8221;, &#8220;&#8221;, &#8220;\&#8221;) &#38; &#8220;clip.gif&#8221;
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
If FrameCount &#60; TotalFrames Then
Image1(FrameCount).Visible = False
FrameCount = FrameCount [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Dim FrameCount As Long</p>
<p>Private Sub Command1_Click()<br />
Timer1.Enabled = False<br />
If LoadGif(Text1, Image1) Then<br />
FrameCount = 0<br />
Timer1.Interval = CLng(Image1(0).Tag)<br />
Timer1.Enabled = True<br />
End If<br />
End Sub</p>
<p>Private Sub Command2_Click()<br />
Timer1.Enabled = False<br />
End Sub</p>
<p>Private Sub Command3_Click()<br />
Timer1.Enabled = True<br />
End Sub</p>
<p>Private Sub Form_Load()</p>
<p>Text1.Text = App.Path &amp; IIf(Right(App.Path, 1) = &#8220;\&#8221;, &#8220;&#8221;, &#8220;\&#8221;) &amp; &#8220;clip.gif&#8221;<br />
Timer1.Enabled = False<br />
End Sub</p>
<p>Private Sub Timer1_Timer()<br />
If FrameCount &lt; TotalFrames Then<br />
Image1(FrameCount).Visible = False<br />
FrameCount = FrameCount + 1<br />
Image1(FrameCount).Visible = True<br />
Timer1.Interval = CLng(Image1(FrameCount).Tag)<br />
Else<br />
FrameCount = 0<br />
For i = 1 To Image1.Count - 1<br />
Image1(i).Visible = False<br />
Next i<br />
Image1(FrameCount).Visible = True<br />
Timer1.Interval = CLng(Image1(FrameCount).Tag)<br />
End If<br />
End Sub</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/programmervb.wordpress.com/104/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/programmervb.wordpress.com/104/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmervb.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmervb.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmervb.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmervb.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmervb.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmervb.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmervb.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmervb.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmervb.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmervb.wordpress.com/104/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmervb.wordpress.com&blog=3238720&post=104&subd=programmervb&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://programmervb.wordpress.com/2008/07/14/knife-animation/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/programmervb-128.jpg" medium="image">
			<media:title type="html">Ed</media:title>
		</media:content>
	</item>
		<item>
		<title>Play Music With VB</title>
		<link>http://programmervb.wordpress.com/2008/07/08/play-music-with-vb/</link>
		<comments>http://programmervb.wordpress.com/2008/07/08/play-music-with-vb/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 05:16:48 +0000</pubDate>
		<dc:creator>programmervb</dc:creator>
		
		<category><![CDATA[Source Code]]></category>

		<category><![CDATA[Play Music With VB]]></category>

		<guid isPermaLink="false">http://programmervb.wordpress.com/?p=102</guid>
		<description><![CDATA[00000000000000000000000000000000000000000
:  Welcome www.programmervb.wordpress.com :
00000000000000000000000000000000000000000
&#8216;Add 8 CommandButtons, 1 Timer, 2 Labels and 1 TextBox
&#8216;Play Music With CD
&#8216;Form
Option Explicit
Dim fastForwardSpeed As Long    &#8216; seconds to seek for ff/rew
Dim fPlaying As Boolean         &#8216; true if CD is currently playing
Dim fCDLoaded As Boolean        &#8216; true if CD is the the player
Dim numTracks As Integer        &#8216; number of tracks on [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>00000000000000000000000000000000000000000<br />
:  Welcome www.programmervb.wordpress.com :<br />
00000000000000000000000000000000000000000</p>
<p>&#8216;Add 8 CommandButtons, 1 Timer, 2 Labels and 1 TextBox<br />
&#8216;Play Music With CD<br />
&#8216;Form</p>
<p>Option Explicit</p>
<p>Dim fastForwardSpeed As Long    &#8216; seconds to seek for ff/rew<br />
Dim fPlaying As Boolean         &#8216; true if CD is currently playing<br />
Dim fCDLoaded As Boolean        &#8216; true if CD is the the player<br />
Dim numTracks As Integer        &#8216; number of tracks on audio CD<br />
Dim trackLength() As String     &#8216; array containing length of each track<br />
Dim track As Integer            &#8216; current track<br />
Dim min As Integer              &#8216; current minute on track<br />
Dim sec As Integer              &#8216; current second on track<br />
Dim cmd As String               &#8216; string to hold mci command strings</p>
<p>&#8216; Send a MCI command string<br />
&#8216; If fShowError is true, display a message box on error<br />
Private Function SendMCIString(cmd As String, fShowError As Boolean) As Boolean<br />
Static rc As Long<br />
Static errStr As String * 200</p>
<p>rc = mciSendString(cmd, 0, 0, hWnd)<br />
If (fShowError And rc &lt;&gt; 0) Then<br />
mciGetErrorString rc, errStr, Len(errStr)<br />
MsgBox errStr<br />
End If<br />
SendMCIString = (rc = 0)<br />
End Function</p>
<p>Private Sub Form_Load()</p>
<p>&#8216; If we&#8217;re already running, then quit<br />
If (App.PrevInstance = True) Then<br />
End<br />
End If</p>
<p>&#8216; Initialize variables<br />
Timer1.Enabled = False<br />
fastForwardSpeed = 5<br />
fCDLoaded = False</p>
<p>&#8216; If the cd is being used, then quit<br />
If (SendMCIString(&#8221;open cdaudio alias cd wait shareable&#8221;, True) = False) Then<br />
End<br />
End If</p>
<p>SendMCIString &#8220;set cd time format tmsf wait&#8221;, True<br />
Timer1.Enabled = True</p>
<p>End Sub</p>
<p>Private Sub Form_Unload(Cancel As Integer)<br />
&#8216;Close all MCI devices opened by this program<br />
SendMCIString &#8220;close all&#8221;, False<br />
End Sub</p>
<p>&#8216; Play the CD<br />
Private Sub play_Click()<br />
SendMCIString &#8220;play cd&#8221;, True<br />
fPlaying = True<br />
End Sub<br />
&#8216; Stop the CD play<br />
Private Sub stopbtn_Click()<br />
SendMCIString &#8220;stop cd wait&#8221;, True<br />
cmd = &#8220;seek cd to &#8221; &amp; track<br />
SendMCIString cmd, True<br />
fPlaying = False<br />
Update<br />
End Sub<br />
&#8216; Pause the CD<br />
Private Sub pause_Click()<br />
SendMCIString &#8220;pause cd&#8221;, True<br />
fPlaying = False<br />
Update<br />
End Sub<br />
&#8216; Eject the CD<br />
Private Sub eject_Click()<br />
SendMCIString &#8220;set cd door open&#8221;, True<br />
Update<br />
End Sub<br />
&#8216; Fast forward<br />
Private Sub ff_Click()<br />
Dim s As String * 40</p>
<p>SendMCIString &#8220;set cd time format milliseconds&#8221;, True<br />
mciSendString &#8220;status cd position wait&#8221;, s, Len(s), 0<br />
If (fPlaying) Then<br />
cmd = &#8220;play cd from &#8221; &amp; CStr(CLng(s) + fastForwardSpeed * 1000)<br />
Else<br />
cmd = &#8220;seek cd to &#8221; &amp; CStr(CLng(s) + fastForwardSpeed * 1000)<br />
End If<br />
mciSendString cmd, 0, 0, 0<br />
SendMCIString &#8220;set cd time format tmsf&#8221;, True<br />
Update<br />
End Sub<br />
&#8216; Rewind the CD<br />
Private Sub rew_Click()<br />
Dim s As String * 40</p>
<p>SendMCIString &#8220;set cd time format milliseconds&#8221;, True<br />
mciSendString &#8220;status cd position wait&#8221;, s, Len(s), 0<br />
If (fPlaying) Then<br />
cmd = &#8220;play cd from &#8221; &amp; CStr(CLng(s) - fastForwardSpeed * 1000)<br />
Else<br />
cmd = &#8220;seek cd to &#8221; &amp; CStr(CLng(s) - fastForwardSpeed * 1000)<br />
End If<br />
mciSendString cmd, 0, 0, 0<br />
SendMCIString &#8220;set cd time format tmsf&#8221;, True<br />
Update<br />
End Sub<br />
&#8216; Forward track<br />
Private Sub ftrack_Click()<br />
If (track &lt; numTracks) Then<br />
If (fPlaying) Then<br />
cmd = &#8220;play cd from &#8221; &amp; track + 1<br />
SendMCIString cmd, True<br />
Else<br />
cmd = &#8220;seek cd to &#8221; &amp; track + 1<br />
SendMCIString cmd, True<br />
End If<br />
Else<br />
SendMCIString &#8220;seek cd to 1&#8243;, True<br />
End If<br />
Update<br />
End Sub<br />
&#8216; Go to previous track<br />
Private Sub btrack_Click()<br />
Dim from As String<br />
If (min = 0 And sec = 0) Then<br />
If (track &gt; 1) Then<br />
from = CStr(track - 1)<br />
Else<br />
from = CStr(numTracks)<br />
End If<br />
Else<br />
from = CStr(track)<br />
End If<br />
If (fPlaying) Then<br />
cmd = &#8220;play cd from &#8221; &amp; from<br />
SendMCIString cmd, True<br />
Else<br />
cmd = &#8220;seek cd to &#8221; &amp; from<br />
SendMCIString cmd, True<br />
End If<br />
Update<br />
End Sub<br />
&#8216; Update the display and state variables<br />
Private Sub Update()<br />
Static s As String * 30</p>
<p>&#8216; Check if CD is in the player<br />
mciSendString &#8220;status cd media present&#8221;, s, Len(s), 0<br />
If (CBool(s)) Then<br />
&#8216; Enable all the controls, get CD information<br />
If (fCDLoaded = False) Then<br />
mciSendString &#8220;status cd number of tracks wait&#8221;, s, Len(s), 0<br />
numTracks = CInt(Mid$(s, 1, 2))<br />
eject.Enabled = True</p>
<p>&#8216; If CD only has 1 track, then it&#8217;s probably a data CD<br />
If (numTracks = 1) Then<br />
Exit Sub<br />
End If</p>
<p>mciSendString &#8220;status cd length wait&#8221;, s, Len(s), 0<br />
totalplay.Caption = &#8220;Tracks: &#8221; &amp; numTracks &amp; &#8220;  Total time: &#8221; &amp; s<br />
ReDim trackLength(1 To numTracks)<br />
Dim i As Integer<br />
For i = 1 To numTracks<br />
cmd = &#8220;status cd length track &#8221; &amp; i<br />
mciSendString cmd, s, Len(s), 0<br />
trackLength(i) = s<br />
Next<br />
play.Enabled = True<br />
pause.Enabled = True<br />
ff.Enabled = True<br />
rew.Enabled = True<br />
ftrack.Enabled = True<br />
btrack.Enabled = True<br />
stopbtn.Enabled = True<br />
fCDLoaded = True<br />
SendMCIString &#8220;seek cd to 1&#8243;, True<br />
End If</p>
<p>&#8216; Update the track time display<br />
mciSendString &#8220;status cd position&#8221;, s, Len(s), 0<br />
track = CInt(Mid$(s, 1, 2))<br />
min = CInt(Mid$(s, 4, 2))<br />
sec = CInt(Mid$(s, 7, 2))<br />
timeWindow.Text = &#8220;[" &amp; Format(track, "00") &amp; "] &#8221; &amp; Format(min, &#8220;00&#8243;) _<br />
&amp; &#8220;:&#8221; &amp; Format(sec, &#8220;00&#8243;)<br />
tracktime.Caption = &#8220;Track time: &#8221; &amp; trackLength(track)</p>
<p>&#8216; Check if CD is playing<br />
mciSendString &#8220;status cd mode&#8221;, s, Len(s), 0<br />
fPlaying = (Mid$(s, 1, 7) = &#8220;playing&#8221;)<br />
Else<br />
eject.Enabled = False<br />
&#8216; Disable all the controls, clear the display<br />
If (fCDLoaded = True) Then<br />
play.Enabled = False<br />
pause.Enabled = False<br />
ff.Enabled = False<br />
rew.Enabled = False<br />
ftrack.Enabled = False<br />
btrack.Enabled = False<br />
stopbtn.Enabled = False<br />
fCDLoaded = False<br />
fPlaying = False<br />
totalplay.Caption = &#8220;&#8221;<br />
tracktime.Caption = &#8220;&#8221;<br />
timeWindow.Text = &#8220;&#8221;<br />
End If<br />
End If<br />
End Sub<br />
&#8216; Set the fast-forward speed<br />
Private Sub ffspeed_Click()<br />
Dim s As String<br />
s = InputBox(&#8221;Enter the new speed in seconds&#8221;, &#8220;Fast Forward Speed&#8221;, CStr(fastForwardSpeed))<br />
If IsNumeric(s) Then<br />
fastForwardSpeed = CLng(s)<br />
End If<br />
End Sub</p>
<p>Private Sub Timer1_Timer()<br />
Update<br />
End Sub</p>
<p>&#8216;Module<br />
Option Explicit</p>
<p>Declare Function mciGetErrorString Lib &#8220;winmm.dll&#8221; Alias &#8220;mciGetErrorStringA&#8221; (ByVal dwError As Long, ByVal lpstrBuffer As String, ByVal uLength As Long) As Long<br />
Declare Function mciSendString Lib &#8220;winmm.dll&#8221; Alias &#8220;mciSendStringA&#8221; (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/programmervb.wordpress.com/102/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/programmervb.wordpress.com/102/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmervb.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmervb.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmervb.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmervb.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmervb.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmervb.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmervb.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmervb.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmervb.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmervb.wordpress.com/102/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmervb.wordpress.com&blog=3238720&post=102&subd=programmervb&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://programmervb.wordpress.com/2008/07/08/play-music-with-vb/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/programmervb-128.jpg" medium="image">
			<media:title type="html">Ed</media:title>
		</media:content>
	</item>
		<item>
		<title>Change Label</title>
		<link>http://programmervb.wordpress.com/2008/07/04/change-label/</link>
		<comments>http://programmervb.wordpress.com/2008/07/04/change-label/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 14:37:38 +0000</pubDate>
		<dc:creator>programmervb</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[Change Label]]></category>

		<guid isPermaLink="false">http://programmervb.wordpress.com/?p=100</guid>
		<description><![CDATA[&#8216;add 1 Label and 1 command button
Private Sub Command1_Click()
Label1.Move (0)
Label1.Caption = Berubah!!!&#8221;
End Sub
       ]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>&#8216;add 1 Label and 1 command button</p>
<p>Private Sub Command1_Click()<br />
Label1.Move (0)<br />
Label1.Caption = Berubah!!!&#8221;<br />
End Sub</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/programmervb.wordpress.com/100/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/programmervb.wordpress.com/100/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmervb.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmervb.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmervb.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmervb.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmervb.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmervb.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmervb.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmervb.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmervb.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmervb.wordpress.com/100/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmervb.wordpress.com&blog=3238720&post=100&subd=programmervb&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://programmervb.wordpress.com/2008/07/04/change-label/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/programmervb-128.jpg" medium="image">
			<media:title type="html">Ed</media:title>
		</media:content>
	</item>
		<item>
		<title>Another Games</title>
		<link>http://programmervb.wordpress.com/2008/07/04/another-games/</link>
		<comments>http://programmervb.wordpress.com/2008/07/04/another-games/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 14:29:32 +0000</pubDate>
		<dc:creator>programmervb</dc:creator>
		
		<category><![CDATA[Games]]></category>

		<category><![CDATA[Another Games]]></category>

		<guid isPermaLink="false">http://programmervb.wordpress.com/?p=97</guid>
		<description><![CDATA[&#8216;add 1 timer and 2 command buttons
Dim wkday
Dim mnthday
Dim mnth
Private Sub comm2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Randomize ( 
comm1.Visible = True
comm2.Visible = False
comm1.ForeColor = QBColor(Rnd(8))
End Sub
Private Sub comm1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Randomize ( 
comm1.Visible = False
comm2.Visible = True
comm2.ForeColor = QBColor(Rnd(8))
End Sub
Private Sub [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>&#8216;add 1 timer and 2 command buttons<br />
Dim wkday<br />
Dim mnthday<br />
Dim mnth</p>
<p>Private Sub comm2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)<br />
Randomize ( <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /><br />
comm1.Visible = True<br />
comm2.Visible = False<br />
comm1.ForeColor = QBColor(Rnd(8))<br />
End Sub</p>
<p>Private Sub comm1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)<br />
Randomize ( <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /><br />
comm1.Visible = False<br />
comm2.Visible = True<br />
comm2.ForeColor = QBColor(Rnd(8))<br />
End Sub</p>
<p>Private Sub Form_Load()<br />
Me.Height = 4500<br />
Me.Width = 8500<br />
Me.Left = 1800<br />
Me.Top = 2000</p>
<p>wkday = Weekday(Now)<br />
mnth = Month(Now)<br />
If wkday = 1 Then<br />
wkday = &#8220;Sunday&#8221;<br />
ElseIf wkday = 2 Then<br />
wkday = &#8220;Monday&#8221;<br />
ElseIf wkday = 3 Then<br />
wkday = &#8220;Tuesday&#8221;<br />
ElseIf wkday = 4 Then<br />
wkday = &#8220;Wednesday&#8221;<br />
ElseIf wkday = 5 Then<br />
wkday = &#8220;Thursday&#8221;<br />
ElseIf wkday = 6 Then<br />
wkday = &#8220;Friday&#8221;<br />
ElseIf wkday = 7 Then<br />
wkday = &#8220;Saturday&#8221;<br />
End If<br />
If mnth = 1 Then<br />
mnth = &#8220;January&#8221;<br />
ElseIf mnth = 2 Then<br />
mnth = &#8220;February&#8221;<br />
ElseIf mnth = 3 Then<br />
mnth = &#8220;March&#8221;<br />
ElseIf mnth = 4 Then<br />
mnth = &#8220;April&#8221;<br />
ElseIf mnth = 5 Then<br />
mnth = &#8220;May&#8221;<br />
ElseIf mnth = 6 Then<br />
mnth = &#8220;June&#8221;<br />
ElseIf mnth = 7 Then<br />
mnth = &#8220;July&#8221;<br />
ElseIf mnth = 8 Then<br />
mnth = &#8220;August&#8221;<br />
ElseIf mnth = 9 Then<br />
mnth = &#8220;September&#8221;<br />
ElseIf mnth = 10 Then<br />
mnth = &#8220;October&#8221;<br />
ElseIf mnth = 11 Then<br />
mnth = &#8220;November&#8221;<br />
ElseIf mnth = 12 Then<br />
mnth = &#8220;December&#8221;<br />
End If<br />
End Sub</p>
<p>Private Sub Timer1_Timer()<br />
Me.Caption = Time &amp; &#8220;, &#8221; &amp; wkday &amp; &#8220;, &#8221; &amp; mnth &amp; &#8221; &#8221; &amp; Day(Now) &amp; &#8220;, &#8221; &amp; Year(Now)<br />
timelbl.Caption = Time &amp; &#8220;, &#8221; &amp; wkday &amp; &#8220;, &#8221; &amp; mnth &amp; &#8221; &#8221; &amp; Day(Now) &amp; &#8220;, &#8221; &amp; Year(Now)<br />
End Sub</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/programmervb.wordpress.com/97/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/programmervb.wordpress.com/97/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmervb.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmervb.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmervb.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmervb.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmervb.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmervb.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmervb.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmervb.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmervb.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmervb.wordpress.com/97/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmervb.wordpress.com&blog=3238720&post=97&subd=programmervb&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://programmervb.wordpress.com/2008/07/04/another-games/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/programmervb-128.jpg" medium="image">
			<media:title type="html">Ed</media:title>
		</media:content>
	</item>
		<item>
		<title>Upper and Lower case</title>
		<link>http://programmervb.wordpress.com/2008/07/02/upper-and-lower-case/</link>
		<comments>http://programmervb.wordpress.com/2008/07/02/upper-and-lower-case/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 10:30:36 +0000</pubDate>
		<dc:creator>programmervb</dc:creator>
		
		<category><![CDATA[Source Code]]></category>

		<category><![CDATA[Upper and Lower case]]></category>

		<guid isPermaLink="false">http://programmervb.wordpress.com/?p=93</guid>
		<description><![CDATA[&#8216;add 2 command buttons and 1 text
Private Sub Command1_Click()
Text1.Text = CapFirst$(Text1.Text)
End Sub
Private Sub Command2_Click()
Text1.Text = LCase$(Text1.Text)
End Sub
&#8216;add 1 module
Declare Function CapFirst$ Lib &#8220;CAPFIRST.DLL&#8221; Alias &#8220;CAPFIRST&#8221; (ByVal St$)
       ]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>&#8216;add 2 command buttons and 1 text</p>
<p>Private Sub Command1_Click()<br />
Text1.Text = CapFirst$(Text1.Text)<br />
End Sub</p>
<p>Private Sub Command2_Click()<br />
Text1.Text = LCase$(Text1.Text)<br />
End Sub</p>
<p>&#8216;add 1 module<br />
Declare Function CapFirst$ Lib &#8220;CAPFIRST.DLL&#8221; Alias &#8220;CAPFIRST&#8221; (ByVal St$)</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/programmervb.wordpress.com/93/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/programmervb.wordpress.com/93/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmervb.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmervb.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmervb.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmervb.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmervb.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmervb.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmervb.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmervb.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmervb.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmervb.wordpress.com/93/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmervb.wordpress.com&blog=3238720&post=93&subd=programmervb&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://programmervb.wordpress.com/2008/07/02/upper-and-lower-case/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/programmervb-128.jpg" medium="image">
			<media:title type="html">Ed</media:title>
		</media:content>
	</item>
		<item>
		<title>Register Editor With VB</title>
		<link>http://programmervb.wordpress.com/2008/06/28/register-editor-with-vb/</link>
		<comments>http://programmervb.wordpress.com/2008/06/28/register-editor-with-vb/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 07:19:42 +0000</pubDate>
		<dc:creator>programmervb</dc:creator>
		
		<category><![CDATA[Source Code]]></category>

		<category><![CDATA[Register Editor With VB]]></category>

		<guid isPermaLink="false">http://programmervb.wordpress.com/?p=90</guid>
		<description><![CDATA[&#8216;add 1 ListView, 1 treeview, 1 ImageList, 1 Label and 1 text
Option Explicit
Dim OsVers As OsVersionInfo
Private Sub ResizeControls()
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
&#8216;Resize controls when the user resizes the form
&#8216;or moves the splitter bar.
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
On Error GoTo ReSizeError
TreeView1.Move 5 * Screen.TwipsPerPixelX, TreeView1.Top, Picture1.Left - 5 * Screen.TwipsPerPixelX, ScaleHeight - TreeView1.Top - Text1.Height - 5 * Screen.TwipsPerPixelY
ListView1.Move Picture1.Left + Picture1.Width, TreeView1.Top, ScaleWidth [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>&#8216;add 1 ListView, 1 treeview, 1 ImageList, 1 Label and 1 text</p>
<p>Option Explicit<br />
Dim OsVers As OsVersionInfo</p>
<p>Private Sub ResizeControls()<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;Resize controls when the user resizes the form<br />
&#8216;or moves the splitter bar.<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
On Error GoTo ReSizeError<br />
TreeView1.Move 5 * Screen.TwipsPerPixelX, TreeView1.Top, Picture1.Left - 5 * Screen.TwipsPerPixelX, ScaleHeight - TreeView1.Top - Text1.Height - 5 * Screen.TwipsPerPixelY<br />
ListView1.Move Picture1.Left + Picture1.Width, TreeView1.Top, ScaleWidth - Picture1.Left - Picture1.Width - 5 * Screen.TwipsPerPixelX, TreeView1.Height<br />
Picture1.Top = TreeView1.Top<br />
Picture1.Height = TreeView1.Height</p>
<p>Label1.Left = TreeView1.Left + 60</p>
<p>Text1.Move TreeView1.Left, ScaleHeight - Text1.Height, ScaleWidth - 2 * TreeView1.Left<br />
Exit Sub<br />
ReSizeError:<br />
Exit Sub</p>
<p>End Sub</p>
<p>Private Sub Form_DragDrop(Source As Control, x As Single, y As Single)<br />
If Source = Picture1 Then<br />
Picture1.Left = x<br />
ResizeControls<br />
End If</p>
<p>End Sub</p>
<p>Private Sub Form_Load()<br />
Width = 600 * Screen.TwipsPerPixelX<br />
Picture1.Width = 5 * Screen.TwipsPerPixelX<br />
Picture1.Left = 250 * Screen.TwipsPerPixelX<br />
Dim nodX As Node<br />
Dim ClmHdr As ColumnHeader</p>
<p>&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; add columns to listview control<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Set ClmHdr = ListView1.ColumnHeaders.Add()<br />
ClmHdr.Text = &#8220;Name&#8221;<br />
ClmHdr.Width = ListView1.Width / 3<br />
Set ClmHdr = Me.ListView1.ColumnHeaders.Add()<br />
ClmHdr.Text = &#8220;Data&#8221;<br />
ClmHdr.Width = 3 * ListView1.Width / 2<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;First we find out what Windows is running. There are a<br />
&#8216;couple of registry keys in Win95 that are not present<br />
&#8216;in Windows NT<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
OsVers.dwVersionInfoSize = 148&amp;<br />
lTempLong = GetVersionEx(OsVers)<br />
Select Case OsVers.dwPlatform<br />
Case VER_PLATFORM_WIN32_NT<br />
iWinVers = WinNt<br />
Case VER_PLATFORM_WIN32_WINDOWS<br />
iWinVers = Win32<br />
Case Else &#8216;Shouldn&#8217;t happen<br />
MsgBox &#8220;This program is intended only for use with 32-bit Windows versions.&#8221;<br />
Unload Form1<br />
End Select</p>
<p>&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;Start the TreeView with a toplevel key<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Set nodX = TreeView1.Nodes.Add(, , &#8220;main&#8221;, &#8220;My Computer&#8221;, 3)</p>
<p>&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;Put in Public main keys<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Set nodX = TreeView1.Nodes.Add(&#8221;main&#8221;, tvwChild, &#8220;HKEY_CLASSES_ROOT&#8221;, &#8220;HKEY_CLASSES_ROOT&#8221;, 1)<br />
nodX.EnsureVisible &#8216;Forces the tree open to this level<br />
nodX.ExpandedImage = 2<br />
nodX.SelectedImage = 2<br />
RegEnumKeys nodX, False &#8216;Enumerate a single rgeSubKey, to put a + on the key<br />
Set nodX = TreeView1.Nodes.Add(&#8221;main&#8221;, tvwChild, &#8220;HKEY_CURRENT_USER&#8221;, &#8220;HKEY_CURRENT_USER&#8221;, 1)<br />
nodX.ExpandedImage = 2<br />
nodX.SelectedImage = 2<br />
RegEnumKeys nodX, False<br />
Set nodX = TreeView1.Nodes.Add(&#8221;main&#8221;, tvwChild, &#8220;HKEY_LOCAL_MACHINE&#8221;, &#8220;HKEY_LOCAL_MACHINE&#8221;, 1)<br />
nodX.ExpandedImage = 2<br />
nodX.SelectedImage = 2<br />
RegEnumKeys nodX, False<br />
Set nodX = TreeView1.Nodes.Add(&#8221;main&#8221;, tvwChild, &#8220;HKEY_USERS&#8221;, &#8220;HKEY_USERS&#8221;, 1)<br />
nodX.ExpandedImage = 2<br />
nodX.SelectedImage = 2<br />
RegEnumKeys nodX, False</p>
<p>&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;Put in version-specific main keys<br />
&#8216;HKEY_PERFORMANCE_DATA does not respond in a normal fashion<br />
&#8216;to key queries.  Note it does not appear in REGEDT32.<br />
&#8216;If iWinVers = WinNT Then<br />
&#8216;treeview1.AddItem &#8220;HKEY_PERFORMANCE_DATA&#8221;<br />
&#8216;End If<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
If iWinVers = Win32 Then<br />
Set nodX = TreeView1.Nodes.Add(&#8221;main&#8221;, tvwChild, &#8220;HKEY_CURRENT_CONFIG&#8221;, &#8220;HKEY_CURRENT_CONFIG&#8221;, 1)<br />
nodX.ExpandedImage = 2<br />
nodX.SelectedImage = 2<br />
RegEnumKeys nodX, False<br />
Set nodX = TreeView1.Nodes.Add(&#8221;main&#8221;, tvwChild, &#8220;HKEY_DYN_DATA&#8221;, &#8220;HKEY_DYN_DATA&#8221;, 1)<br />
nodX.ExpandedImage = 2<br />
nodX.SelectedImage = 2<br />
RegEnumKeys nodX, False<br />
End If<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;Setup hourglass cursor<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
iWaitCursor = LoadCursor(0, IDC_WAIT)</p>
<p>End Sub</p>
<p>Private Sub Form_Resize()<br />
ResizeControls<br />
End Sub</p>
<p>Private Sub listview1_DblClick()<br />
&#8216; if nothing selected get out<br />
If Not (ListView1.SelectedItem Is Nothing) Then<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
&#8216;Call EditRegValue to load the value into the editor.<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
EditRegValue TreeView1.Nodes(TreeView1.SelectedItem.Key), CLng(ListView1.ListItems(ListView1.SelectedItem.Index).Tag)<br />
End If</p>
<p>End Sub</p>
<p>Private Sub ListView1_DragDrop(Source As Control, x As Single, y As Single)<br />
If Source = Picture1 Then<br />
Picture1.Left = x + ListView1.Left<br />
ResizeControls<br />
End If</p>
<p>End Sub</p>
<p>Private Sub TreeView1_Collapse(ByVal Node As ComctlLib.Node)<br />
Text1 = truncatepath(Node.FullPath, Me, Text1)</p>
<p>End Sub</p>
<p>Private Sub TreeView1_DragDrop(Source As Control, x As Single, y As Single)<br />
If Source = Picture1 Then<br />
Picture1.Left = x + TreeView1.Left<br />
ResizeControls<br />
End If<br />
End Sub</p>
<p>Private Sub TreeView1_Expand(ByVal Node As Node)<br />
If Node.Children &gt; 1 Then Exit Sub<br />
If Node.Text = &#8220;My Computer&#8221; Then Exit Sub<br />
RegEnumKeys Node, True<br />
Node.Sorted = True</p>
<p>End Sub</p>
<p>Private Sub TreeView1_NodeClick(ByVal Node As Node)</p>
<p>&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;Empty the value list.<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
ListView1.ListItems.Clear</p>
<p>&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;Remember which line was clicked when we start<br />
&#8216;   moving up and down the list.<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>rgeSubKey = Node.FullPath<br />
Text1 = truncatepath(Node.FullPath, Me, Text1)<br />
If rgeSubKey = &#8220;My Computer&#8221; Then Exit Sub<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;Now enumerate all values belonging to this key<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
ListView1.Sorted = False<br />
RegEnumValues<br />
ListView1.Sorted = True<br />
End Sub</p>
<p>&#8216;Now the module</p>
<p>Option Explicit</p>
<p>Type FILETIME<br />
lLowDateTime    As Long<br />
lHighDateTime   As Long<br />
End Type</p>
<p>Type OsVersionInfo<br />
dwVersionInfoSize As Long<br />
dwMajorVersion As Long<br />
dwMinorVersion As Long<br />
dwBuildNumber As Long<br />
dwPlatform As Long<br />
szCSDVersion As String * 128<br />
End Type</p>
<p>Declare Function RegOpenKeyEx&amp; Lib &#8220;advapi32.dll&#8221; Alias &#8220;RegOpenKeyExA&#8221; (ByVal hKey&amp;, ByVal lpszSubKey$, dwOptions&amp;, ByVal samDesired&amp;, lpHKey&#038;amp <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Declare Function RegCloseKey&amp; Lib &#8220;advapi32.dll&#8221; (ByVal hKey&#038;amp <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Declare Function RegQueryValueEx&amp; Lib &#8220;advapi32.dll&#8221; Alias &#8220;RegQueryValueExA&#8221; (ByVal hKey&amp;, ByVal lpszValueName$, ByVal lpdwRes&amp;, lpdwType&amp;, ByVal lpDataBuff$, nSize&#038;amp <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Declare Function RegSetValueEx&amp; Lib &#8220;advapi32.dll&#8221; Alias &#8220;RegSetValueExA&#8221; (ByVal hKey&amp;, ByVal lpszValueName$, ByVal dwRes&amp;, ByVal dwType&amp;, lpDataBuff As Any, ByVal nSize&#038;amp <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Declare Function RegConnectRegistry&amp; Lib &#8220;advapi32.dll&#8221; (ByVal lpMachineName$, ByVal hKey&amp;, phkResult&#038;amp <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Declare Function RegCreateKeyEx&amp; Lib &#8220;advapi32.dll&#8221; Alias &#8220;RegCreateKeyExA&#8221; (ByVal hKey&amp;, ByVal lpSubKey$, ByVal Reserved&amp;, ByVal lpClass$, ByVal dwOptions&amp;, ByVal samDesired&amp;, lpSecurityAttributes&amp;, phkResult&amp;, lpdwDisposition&#038;amp <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Declare Function RegFlushKey&amp; Lib &#8220;advapi32.dll&#8221; (ByVal hKey&#038;amp <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Declare Function RegEnumKeyEx&amp; Lib &#8220;advapi32.dll&#8221; Alias &#8220;RegEnumKeyExA&#8221; (ByVal hKey&amp;, ByVal dwIndex&amp;, ByVal lpname$, lpcbName&amp;, ByVal lpReserved&amp;, ByVal lpClass$, lpcbClass&amp;, lpftLastWriteTime As FILETIME)</p>
<p>Declare Function RegEnumValue&amp; Lib &#8220;advapi32.dll&#8221; Alias _<br />
&#8220;RegEnumValueA&#8221; (ByVal hKey&amp;, ByVal dwIndex&amp;, ByVal lpname$, _<br />
lpcbName&amp;, ByVal lpReserved&amp;, lpdwType&amp;, lpValue As Any, lpcbValue&#038;amp <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Declare Function RegQueryInfoKey&amp; Lib &#8220;advapi32.dll&#8221; Alias &#8220;RegQueryInfoKeyA&#8221; (ByVal hKey&amp;, ByVal lpClass$, lpcbClass&amp;, ByVal lpReserved&amp;, lpcSubKeys&amp;, lpcbMaxSubKeyLen&amp;, lpcbMaxClassLen&amp;, lpcValues&amp;, lpcbMaxValueNameLen&amp;, lpcbMaxValueLen&amp;, lpcbSecurityDescriptor&amp;, lpftLastWriteTime As FILETIME)</p>
<p>Declare Function GetVersionEx&amp; Lib &#8220;kernel32.dll&#8221; Alias &#8220;GetVersionExA&#8221; (lpStruct As OsVersionInfo)</p>
<p>Declare Function LoadCursor&amp; Lib &#8220;User32&#8243; Alias &#8220;LoadCursorA&#8221; (ByVal hInstance&amp;, ByVal lpCursor&#038;amp <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Declare Function SetCursor&amp; Lib &#8220;User32&#8243; (ByVal hCursor&#038;amp <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Public Const IDC_WAIT = 32514&amp;</p>
<p>Public iWaitCursor&amp;</p>
<p>Public lNewKey&amp; &#8216;used to generate unique Node keys</p>
<p>Const ERROR_SUCCESS = 0&amp;<br />
Const ERROR_BADDB = 1009&amp;<br />
Const ERROR_BADKEY = 1010&amp;<br />
Const ERROR_CANTOPEN = 1011&amp;<br />
Const ERROR_CANTREAD = 1012&amp;<br />
Const ERROR_CANTWRITE = 1013&amp;<br />
Const ERROR_OUTOFMEMORY = 14&amp;<br />
Const ERROR_INVALID_PARAMETER = 87&amp;<br />
Const ERROR_ACCESS_DENIED = 5&amp;<br />
Const ERROR_NO_MORE_ITEMS = 259&amp;<br />
Const ERROR_MORE_DATA = 234&amp;</p>
<p>Public Const HKEY_CLASSES_ROOT = &amp;H80000000<br />
Public Const HKEY_CURRENT_USER = &amp;H80000001<br />
Public Const HKEY_LOCAL_MACHINE = &amp;H80000002<br />
Public Const HKEY_USERS = &amp;H80000003<br />
Public Const HKEY_PERFORMANCE_DATA = &amp;H80000004<br />
Public Const HKEY_CURRENT_CONFIG = &amp;H80000005<br />
Public Const HKEY_DYN_DATA = &amp;H80000006</p>
<p>Public Const LB_SETHORIZONTALEXTENT = &amp;H400 + 21</p>
<p>Const REG_NONE = 0&amp;                        &#8216; No value type<br />
Public Const REG_SZ = 1&amp;                   &#8216; Unicode nul terminated string<br />
Const REG_EXPAND_SZ = 2&amp;                   &#8216; Unicode nul terminated string<br />
&#8216; (with environment variable references)<br />
Const REG_BINARY = 3&amp;                      &#8216; Free form binary<br />
Public Const REG_DWORD = 4&amp;                &#8216; 32-bit number<br />
Const REG_DWORD_LITTLE_ENDIAN = 4&amp;         &#8216; 32-bit number (same as REG_DWORD)<br />
Const REG_DWORD_BIG_ENDIAN = 5&amp;            &#8216; 32-bit number<br />
Const REG_LINK = 6&amp;                        &#8216; Symbolic Link (unicode)<br />
Const REG_MULTI_SZ = 7&amp;                    &#8216; Multiple Unicode strings<br />
Const REG_RESOURCE_LIST = 8&amp;               &#8216; Resource list in the resource map<br />
Const REG_FULL_RESOURCE_DESCRIPTOR = 9&amp;    &#8216; Resource list in the hardware description<br />
Const REG_RESOURCE_REQUIREMENTS_LIST = 10&amp;</p>
<p>Const KEY_QUERY_VALUE = &amp;H1&amp;<br />
Const KEY_SET_VALUE = &amp;H2&amp;<br />
Const KEY_CREATE_SUB_KEY = &amp;H4&amp;<br />
Const KEY_ENUMERATE_SUB_KEYS = &amp;H8&amp;<br />
Const KEY_NOTIFY = &amp;H10&amp;<br />
Const KEY_CREATE_LINK = &amp;H20&amp;<br />
Const READ_CONTROL = &amp;H20000<br />
Const WRITE_DAC = &amp;H40000<br />
Const WRITE_OWNER = &amp;H80000<br />
Const SYNCHRONIZE = &amp;H100000<br />
Const STANDARD_RIGHTS_REQUIRED = &amp;HF0000<br />
Const STANDARD_RIGHTS_READ = READ_CONTROL<br />
Const STANDARD_RIGHTS_WRITE = READ_CONTROL<br />
Const STANDARD_RIGHTS_EXECUTE = READ_CONTROL<br />
Const KEY_READ = STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY<br />
Const KEY_WRITE = STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY<br />
Const KEY_EXECUTE = KEY_READ</p>
<p>Public iWinVers%<br />
Public Const WinNt = 1<br />
Public Const Win32 = 2</p>
<p>Public Const VER_PLATFORM_WIN32_WINDOWS = 1<br />
Public Const VER_PLATFORM_WIN32_NT = 2</p>
<p>Public lTempLong&amp;<br />
Public fTempDbl#<br />
Public sTempString$<br />
Public nodetemp As Node</p>
<p>Public rgeEntry$<br />
Public rgeDataType&amp;<br />
Public rgeValue$<br />
Public rgeMainKey&amp;<br />
Public rgeSubKey$</p>
<p>Public Sub rgeExtractKeys()<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&#8216;Enter with rgeSubKey containing a full path in the<br />
&#8216;My Computer\HKEY_&#8230;\..\ format or HKEY_&#8230;\&#8230;\ format<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
If Left$(rgeSubKey, 12) = &#8220;My Computer\&#8221; Then<br />
rgeSubKey = Right$(rgeSubKey, Len(rgeSubKey) - 12)<br />
End If</p>
<p>&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
&#8216;If there is no main key we have to assume it may already have<br />
&#8216;been extracted.<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
If Left$(rgeSubKey, 5) &lt;&gt; &#8220;HKEY_&#8221; Then<br />
Exit Sub<br />
ElseIf InStr(rgeSubKey, &#8220;\&#8221;) = 0 Then<br />
rgeMainKey = GetMainKey(rgeSubKey)<br />
rgeSubKey = &#8220;&#8221;<br />
Else<br />
rgeMainKey = GetMainKey(Left$(rgeSubKey, InStr(rgeSubKey, &#8220;\&#8221;) - 1))<br />
rgeSubKey = Right$(rgeSubKey, Len(rgeSubKey) - InStr(rgeSubKey, &#8220;\&#8221;))<br />
End If<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Check rgeMainKey&amp; for validity<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
If rgeMainKey &lt; &amp;H80000000 Or rgeMainKey &gt; &amp;H80000006 Then<br />
rgeClear<br />
End If</p>
<p>End Sub<br />
Public Sub rgeClear()<br />
rgeMainKey = 0<br />
rgeSubKey = &#8220;&#8221;<br />
rgeValue = &#8220;&#8221;<br />
rgeDataType = 0<br />
rgeEntry = &#8220;&#8221;<br />
End Sub</p>
<p>Sub EditRegValue(ByVal nodX As Node, lRegIndex&#038;amp <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Specific to the RegDemo application.<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
rgeSubKey = nodX.FullPath<br />
rgeSubKey = Right$(rgeSubKey, Len(rgeSubKey) - 12)<br />
If InStr(rgeSubKey, &#8220;\&#8221;) = 0 Then<br />
rgeMainKey = GetMainKey(rgeSubKey)<br />
rgeSubKey = &#8220;&#8221;<br />
Else<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
&#8216;This must be a SubKey.<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
rgeMainKey = GetMainKey(Left$(rgeSubKey, InStr(rgeSubKey, &#8220;\&#8221;) - 1))<br />
rgeSubKey = Right$(rgeSubKey, Len(rgeSubKey) - InStr(rgeSubKey, &#8220;\&#8221;))<br />
End If</p>
<p>Dim lRtn&amp;       &#8216; Returned by registry functions, should be 0&amp;<br />
Dim hKey&amp;       &#8216; Return handle to opened key<br />
Dim lLenValueName&amp;<br />
Dim lLenValue&amp;<br />
Dim lKeyIndx&amp;</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; values for QueryInfoKey:<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Dim sClassName$<br />
Dim lClassLen&amp;<br />
Dim lSubKeys&amp;<br />
Dim lMaxSubKey&amp;<br />
Dim lMaxClass&amp;<br />
Dim lValues&amp;<br />
Dim lMaxValueName&amp;<br />
Dim lMaxValueData&amp;<br />
Dim lSecurityDesc&amp;<br />
Dim strucLastWriteTime As FILETIME</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Open key<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lRtn = RegOpenKeyEx(rgeMainKey, rgeSubKey, 0&amp;, KEY_READ, hKey)<br />
If lRtn &lt;&gt; ERROR_SUCCESS Then<br />
MsgBox RtnRegError(lRtn)</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; No key open, so leave<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Exit Sub<br />
End If</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; RegQueryInfoKey is used to get the size of the largest<br />
&#8216;   value name and data string.<br />
&#8216; Other returned values are ignored.<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
sClassName = Space$(255) &#8216;initialize these because occasional errors otherwise<br />
lClassLen = CLng(Len(sClassName))<br />
lRtn = RegQueryInfoKey(hKey, sClassName, lClassLen, 0&amp;, lSubKeys, lMaxSubKey, lMaxClass, lValues, lMaxValueName, lMaxValueData, lSecurityDesc, strucLastWriteTime)</p>
<p>&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
&#8216;If the enumeration fails due to a buffer over-run, we will loop back<br />
&#8216;to this point with larger buffers.<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
RetryValueHere:</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Set variables<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
rgeEntry = Space$(lMaxValueName + 1)<br />
lLenValueName = CLng(Len(rgeEntry)) &#8216;+ 1<br />
rgeValue = Space$(lMaxValueData + 1)<br />
lLenValue = CLng(Len(rgeValue))       &#8216;+ 1</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Call the enumeration function to get the indexed value<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lRtn = RegEnumValue(hKey, lRegIndex, rgeEntry, lLenValueName, 0&amp;, rgeDataType, ByVal rgeValue, lLenValue)</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Check for success<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
If lRtn = ERROR_SUCCESS Then<br />
If rgeDataType &lt;&gt; REG_SZ And rgeDataType &lt;&gt; REG_DWORD Then</p>
<p>&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;Tell us what value types may be edited, along with<br />
&#8216;    the type of value found.<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
sTempString = &#8220;This Demo only supports editing of values with types of REG_SZ and REG_DWORD.  This value is of type &#8220;<br />
Select Case rgeDataType<br />
Case 2<br />
sTempString = sTempString &amp; &#8220;REG_EXPAND_SZ.&#8221;<br />
Case 3<br />
sTempString = sTempString &amp; &#8220;REG_BINARY.&#8221;<br />
Case 5<br />
sTempString = sTempString &amp; &#8220;REG_DWORD_BIG_ENDIAN.&#8221;<br />
Case 6<br />
sTempString = sTempString &amp; &#8220;REG_LINK.&#8221;<br />
Case 7<br />
sTempString = sTempString &amp; &#8220;REG_MULTI_SZ.&#8221;<br />
Case 8<br />
sTempString = sTempString &amp; &#8220;REG_RESOURCE_LIST.&#8221;<br />
Case 9<br />
sTempString = sTempString &amp; &#8220;REG_FULL_RESOURCE_DESCRIPTOR.&#8221;<br />
Case 10<br />
sTempString = sTempString &amp; &#8220;REG_RESOURCE_REQUIREMENTS_LIST.&#8221;<br />
End Select<br />
MsgBox sTempString</p>
<p>Else<br />
rgeEntry = Mid$(rgeEntry, 1, lLenValueName)<br />
If lLenValueName = 0 Then<br />
rgeEntry = &#8220;(Default)&#8221;<br />
End If<br />
rgeValue = Mid$(rgeValue, 1, lLenValue)<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Convert DWORD 4 character value to 32-bit<br />
&#8216;   number.<br />
&#8216; First character is low byte, and so on.<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Form2.Caption = &#8220;Edit String Value&#8221;<br />
If rgeDataType = REG_DWORD Then<br />
fTempDbl = Asc(Mid$(rgeValue, 1, 1)) + &amp;H100&amp; * Asc(Mid$(rgeValue, 2, 1)) + &amp;H10000 * Asc(Mid$(rgeValue, 3, 1)) + &amp;H1000000 * CDbl(Asc(Mid$(rgeValue, 4, 1)))<br />
If fTempDbl &gt; &amp;H7FFFFFFF Then<br />
rgeValue = Hex$(fTempDbl - 4294967296#)<br />
Else<br />
rgeValue = Hex$(fTempDbl)<br />
End If<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Turn on Hex/Decimal options<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Form2.Frame1.Visible = True<br />
Form2.Caption = &#8220;Edit DWORD Value&#8221;<br />
End If</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Place the values in the form2 text boxes<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Form2.Text1 = rgeEntry<br />
Form2.Text2 = rgeValue</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Pass the key variables to form2 via hidden<br />
&#8216;   text boxes<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Form2.Show 1<br />
End If</p>
<p>ElseIf lRtn = ERROR_MORE_DATA Then<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; This error means that, despite querying the key<br />
&#8216;   we have not set one of the buffers large<br />
&#8216;   enough. If the buffer is already 20000 we are<br />
&#8216;   not going to be able to edit it.<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
If lMaxValueData &gt;= 20000 Then<br />
MsgBox (&#8221;Value is too large for this editor!&#8221;)<br />
Else</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Increase the buffer sizes and try again<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lMaxValueData = lMaxValueData + 5<br />
lMaxValueName = lMaxValueName + 5<br />
GoTo RetryValueHere<br />
End If<br />
Else</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Key still open, so display the error and fall<br />
&#8216;   thru to the close function below<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
MsgBox RtnRegError(lRtn)<br />
End If</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Always close opened keys!<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lRtn = RegCloseKey(hKey)</p>
<p>End Sub</p>
<p>Function truncatepath$(TPath$, TForm As Form, TControl As Control)<br />
Dim FirstSlash%<br />
On Error GoTo TPathError<br />
TPath = Right$(TPath, Len(TPath) - InStr(TPath, &#8220;H&#8221;) + 1)<br />
FirstSlash = InStr(3, TPath, &#8220;\&#8221;)<br />
Do Until TForm.TextWidth(TPath) &lt;= TControl.Width<br />
lTempLong = InStr(FirstSlash + 5, TPath, &#8220;\&#8221;)<br />
TPath = Left$(TPath, FirstSlash) &amp; &#8220;&#8230;&#8221; &amp; Mid$(TPath, lTempLong, Len(TPath) - lTempLong + 1)<br />
Loop<br />
TooLong:<br />
On Error GoTo StillError<br />
If TForm.TextWidth(TPath) &gt; TControl.Width Then<br />
Do Until TForm.TextWidth(TPath) &lt;= TControl.Width<br />
TPath = Left$(TPath, Len(TPath) - 1)<br />
Loop<br />
TPath = Left$(TPath, Len(TPath) - 3) &amp; &#8220;&#8230;&#8221;<br />
End If<br />
FinishAnyWay:<br />
truncatepath = TPath<br />
Exit Function<br />
TPathError:<br />
Resume TooLong<br />
StillError:<br />
Resume FinishAnyWay<br />
End Function</p>
<p>Function GetMainKey&amp;(keyname$)</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Used to convert main key strings to their values<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Select Case keyname<br />
Case &#8220;HKEY_CLASSES_ROOT&#8221;<br />
GetMainKey = HKEY_CLASSES_ROOT<br />
Case &#8220;HKEY_CURRENT_USER&#8221;<br />
GetMainKey = HKEY_CURRENT_USER<br />
Case &#8220;HKEY_LOCAL_MACHINE&#8221;<br />
GetMainKey = HKEY_LOCAL_MACHINE<br />
Case &#8220;HKEY_USERS&#8221;<br />
GetMainKey = HKEY_USERS<br />
Case &#8220;HKEY_PERFORMANCE_DATA&#8221;<br />
GetMainKey = HKEY_PERFORMANCE_DATA<br />
Case &#8220;HKEY_CURRENT_CONFIG&#8221;<br />
GetMainKey = HKEY_CURRENT_CONFIG<br />
Case &#8220;HKEY_DYN_DATA&#8221;<br />
GetMainKey = HKEY_DYN_DATA<br />
End Select</p>
<p>End Function</p>
<p>Function RegEnumKeys&amp;(ByVal Node As Node, bFullEnumeration As Boolean)<br />
lTempLong = SetCursor(iWaitCursor)<br />
Dim sRoot$, sRoot2$<br />
rgeSubKey = Node.FullPath<br />
If rgeSubKey = &#8220;My Computer&#8221; Then<br />
Exit Function<br />
End If<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&#8216;If we&#8217;ve put in a fake node to set the + image,<br />
&#8216;remove that node to avoid duplication<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
While Node.Children &gt; 0<br />
Form1.TreeView1.Nodes.Remove Node.Child.Key<br />
Wend<br />
Form1.TreeView1.Enabled = False<br />
rgeExtractKeys<br />
sRoot = Node.Key<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; This function will load all subkeys into the TreeView<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Dim lRtn&amp;       &#8216; Returned by registry functions, should be 0&amp;<br />
Dim hKey&amp;       &#8216; Return handle to opened key<br />
Dim strucLastWriteTime    As FILETIME<br />
Dim sSubKeyName$<br />
Dim sClassString$<br />
Dim lLenSubKey&amp;<br />
Dim lLenClass&amp;<br />
Dim lKeyIndx&amp;<br />
Dim lRet&amp;<br />
Dim hKey2&amp;<br />
Dim sSubKey2$<br />
Dim nodX As Node<br />
Dim sNewKey$</p>
<p>&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&#8216;values for QueryInfoKey:<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Dim sClassName$<br />
Dim lClassLen&amp;<br />
Dim lSubKeys&amp;<br />
Dim lMaxSubKey&amp;<br />
Dim sMaxSubKey$<br />
Dim lMaxClass&amp;<br />
Dim sMaxClass$<br />
Dim lValues&amp;<br />
Dim lMaxValueName&amp;<br />
Dim lMaxValueData&amp;<br />
Dim lSecurityDesc&amp;</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Open key<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lRtn = RegOpenKeyEx(rgeMainKey, rgeSubKey, 0&amp;, KEY_READ, hKey)<br />
If lRtn &lt;&gt; ERROR_SUCCESS Then<br />
If lRtn = ERROR_ACCESS_DENIED Then<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&#8216;Grey the key<br />
&#8216;otherwise report error condition<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Node.Image = 6<br />
&#8216;Node.Enabled = False &#8216;Doesn&#8217;t work?<br />
Else<br />
MsgBox RtnRegError(lRtn)<br />
End If<br />
RegEnumKeys = lRtn<br />
Form1.TreeView1.Enabled = True<br />
Exit Function</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; No key open, so leave<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
End If</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; A call to RegQueryInfoKey will tell us the maximum<br />
&#8216;   keyname length<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
sClassName = Space$(255)<br />
lClassLen = CLng(Len(sClassName))<br />
lRet = RegQueryInfoKey(hKey, sClassName, lClassLen, 0&amp;, lSubKeys, lMaxSubKey, lMaxClass, lValues, lMaxValueName, lMaxValueData, lSecurityDesc, strucLastWriteTime)<br />
sMaxSubKey = Space$(lMaxSubKey + 1)<br />
sMaxClass = Space$(lMaxClass + 1)</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Enumerate the keys<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lKeyIndx = 0&amp;<br />
Do While lRtn = ERROR_SUCCESS</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; If the enumeration fails due to a buffer over-run,<br />
&#8216;   we will loop back to this point with larger buffers.<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
ReTryKeyEnumeration:</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Set variables<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
sSubKeyName = sMaxSubKey<br />
lLenSubKey = lMaxSubKey<br />
sClassString = sMaxClass<br />
lLenClass = lMaxClass</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Call the enumeration function<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lRtn = RegEnumKeyEx(hKey, lKeyIndx, sSubKeyName, lLenSubKey, 0&amp;, sClassString, lLenClass, strucLastWriteTime)<br />
If InStr(sSubKeyName, Chr$(0)) &gt; 1 Then<br />
sSubKeyName = Left$(sSubKeyName, InStr(sSubKeyName, Chr$(0)) - 1)<br />
End If</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Check for success<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
If lRtn = ERROR_SUCCESS Then<br />
lNewKey = lNewKey + 1<br />
sNewKey = &#8220;A&#8221; &amp; Format$(lNewKey, &#8220;000000&#8243;)<br />
Set nodX = Form1.TreeView1.Nodes.Add(sRoot, tvwChild, sNewKey, sSubKeyName, 1)<br />
If bFullEnumeration = True Then<br />
sSubKey2 = sSubKeyName<br />
If rgeSubKey &lt;&gt; &#8220;&#8221; Then<br />
sSubKey2 = Trim(rgeSubKey) &amp; &#8220;\&#8221; &amp; sSubKeyName<br />
End If</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Use RegQueryInfoKey to find out if this key has<br />
&#8216;   subkeys<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lRet = RegOpenKeyEx(rgeMainKey, sSubKey2, 0&amp;, KEY_READ, hKey2)<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&#8216;We are fully enumerating a key, so set images and<br />
&#8216;Recurse a single SubKey to set + indicator if there are<br />
&#8217;subkeys below this one<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
If lRet = ERROR_ACCESS_DENIED Then<br />
nodX.ExpandedImage = 6<br />
nodX.SelectedImage = 6<br />
ElseIf lRet = ERROR_SUCCESS Then<br />
nodX.ExpandedImage = 2<br />
nodX.SelectedImage = 2<br />
lRet = RegQueryInfoKey(hKey2, vbNullString, 0&amp;, 0&amp;, lSubKeys, 0&amp;, 0&amp;, 0&amp;, 0&amp;, 0&amp;, 0&amp;, strucLastWriteTime)<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Check for success.  If lSubKeys is greater than zero<br />
&#8216; there are subkeys for this key, and we will set a fake<br />
&#8216; node under this one to make a + symbol.<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
If lRet = ERROR_SUCCESS And lSubKeys &gt; 0 Then<br />
sRoot2 = nodX.Key<br />
lNewKey = lNewKey + 1<br />
sNewKey = &#8220;A&#8221; &amp; Format$(lNewKey, &#8220;000000&#8243;)<br />
Set nodX = Form1.TreeView1.Nodes.Add(sRoot2, tvwChild, sNewKey, &#8220;PlaceHolder&#8221;, 1)<br />
End If<br />
lRet = RegCloseKey(hKey2)<br />
End If<br />
Else<br />
Exit Do<br />
End If<br />
lKeyIndx = lKeyIndx + 1<br />
ElseIf lRtn = ERROR_MORE_DATA Then<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; This error means that, despite querying the key<br />
&#8216;   we have not set one of the buffers large<br />
&#8216;   enough.Increment the buffer sizes and try<br />
&#8216;   again<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lMaxSubKey = lMaxSubKey + 5<br />
lMaxClass = lMaxClass + 5<br />
sMaxSubKey = Space$(lMaxSubKey + 1)<br />
sMaxClass = Space$(lMaxClass + 1)<br />
GoTo ReTryKeyEnumeration<br />
ElseIf lRtn = ERROR_NO_MORE_ITEMS Then<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Not an error, just end of list &#8212; exit the<br />
&#8216;   loop<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lRtn = ERROR_SUCCESS<br />
Exit Do<br />
ElseIf lRtn &lt;&gt; ERROR_SUCCESS Then<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Key still open, so display the error and fall<br />
&#8216;   thru to the close function below<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
MsgBox RtnRegError(lRtn)<br />
Exit Do<br />
End If<br />
Loop</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Set the return to the last error<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
RegEnumKeys = lRtn</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Always close opened keys!<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lRtn = RegCloseKey(hKey)<br />
Form1.TreeView1.Enabled = True<br />
End Function<br />
Public Sub RegEnumValues()<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;Enter with rgeSubKey containing a full key path, in<br />
&#8216;My Computer\HKEY_..\..\ fashion<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;When you don&#8217;t need to enumerate all values, but just want to<br />
&#8216;retrive a single value, use the provided function RegGetValue<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Dim lRtn&amp;        &#8216; Returned by registry functions, should be 0&amp;<br />
Dim hKey&amp;       &#8216; Return handle to opened key<br />
Dim lLenValueName&amp;<br />
Dim lLenValue&amp;<br />
Dim lKeyIndx&amp;<br />
Dim sBinaryString$<br />
Dim Item As ListItem<br />
Dim iTempInt%<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&#8216;values for QueryInfoKey:<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Dim sClassName$<br />
Dim lClassLen&amp;<br />
Dim lSubKeys&amp;<br />
Dim lMaxSubKey&amp;<br />
Dim lMaxClass&amp;<br />
Dim lValues&amp;<br />
Dim lMaxValueName&amp;<br />
Dim lMaxValueData&amp;<br />
Dim lSecurityDesc&amp;<br />
Dim strucLastWriteTime As FILETIME<br />
Dim pbytValueName() As Byte<br />
Dim pbytValue() As Byte<br />
Dim DataType&amp;<br />
Dim ValueName$<br />
Dim ValueVal$</p>
<p>Dim iListWidth%  &#8216;Used to set listbox scrollbar</p>
<p>lTempLong = SetCursor(iWaitCursor)</p>
<p>rgeExtractKeys</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Open key<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lRtn = RegOpenKeyEx(rgeMainKey, rgeSubKey, 0&amp;, KEY_READ, hKey)<br />
If lRtn &lt;&gt; ERROR_SUCCESS Then<br />
If lRtn &lt;&gt; ERROR_ACCESS_DENIED Then<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&#8216;If access is denied don&#8217;t do anything<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
MsgBox RtnRegError(lRtn)<br />
End If<br />
rgeClear</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; No key open, so leave<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Exit Sub<br />
End If</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Use RegQueryInfoKey to get the maximum value data info.<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
sClassName = Space$(255)<br />
lClassLen = CLng(Len(sClassName))<br />
lRtn = RegQueryInfoKey(hKey, sClassName, lClassLen, 0&amp;, lSubKeys, lMaxSubKey, lMaxClass, lValues, lMaxValueName, lMaxValueData, lSecurityDesc, strucLastWriteTime)</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Enumerate the keys<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lKeyIndx = 0&amp;<br />
Do While lRtn = ERROR_SUCCESS And lKeyIndx &lt; lValues<br />
sBinaryString = &#8220;&#8221;</p>
<p>&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
&#8216;If the enumeration fails due to a buffer over-run, we will loop back<br />
&#8216;to this point with larger buffers.<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
ReTryValueEnumeration:</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Set variables<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
ValueName = Space$(lMaxValueName + 1)<br />
lLenValueName = CLng(Len(ValueName)) &#8216;+ 1<br />
ValueVal = Space$(lMaxValueData + 1)<br />
lLenValue = CLng(Len(ValueVal))       &#8216;+ 1</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Call the enumeration function<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;lRtn = RegEnumValue(hKey, lKeyIndx, pbytValueName(0), _<br />
&#8216;lLenValueName, vbNull, rgeDataType, pbytValue(0), _<br />
&#8216;lLenValue)<br />
lRtn = RegEnumValue(hKey, lKeyIndx, ValueName, _<br />
lLenValueName, 0&amp;, DataType, ByVal ValueVal, _<br />
lLenValue)</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Check for success<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
If lRtn = ERROR_SUCCESS Then</p>
<p>rgeEntry = ValueName<br />
rgeDataType = DataType<br />
rgeValue = ValueVal<br />
&#8216;rgeValue = pbytValue()<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;Add an item to the list box<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Set Item = Form1.ListView1.ListItems.Add()</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Start building the entry to put in the list box:<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
rgeEntry = Mid$(rgeEntry, 1, lLenValueName)</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Default values don&#8217;t have a name.<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
If lLenValueName = 0 Then<br />
rgeEntry = &#8220;(Default)&#8221;<br />
End If</p>
<p>rgeValue = Mid$(rgeValue, 1, lLenValue)<br />
Select Case rgeDataType<br />
Case REG_MULTI_SZ<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; REG_MULTI_SZ strings are a series of<br />
&#8216;   zero terminated strings. If we don&#8217;t<br />
&#8216;   strip out the zeros, only the first<br />
&#8216;   one will display.<br />
&#8216; We will replace them with spaces.<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Item.SmallIcon = 4<br />
Do While InStr(rgeValue, Chr$(0))<br />
rgeValue = Left$(rgeValue, InStr(rgeValue, Chr$(0)) - 1) &amp; &#8221; &#8221; &amp; Right$(rgeValue, Len(rgeValue) - InStr(rgeValue, Chr$(0)))<br />
Loop<br />
Case REG_SZ<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; REG_SZ values are zero-terminated<br />
&#8216;   strings, and are the most common<br />
&#8216;   values.<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Item.SmallIcon = 4</p>
<p>&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&#8216;Put quotes around the string<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
rgeValue = &#8220;&#8221;"&#8221; &amp; Left$(rgeValue, lLenValue - 1) &amp; &#8220;&#8221;"&#8221;</p>
<p>Case REG_EXPAND_SZ<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&#8216;Environmental variables that are binary<br />
&#8216;but evaluate as strings.  Not edited by<br />
&#8216;this program.<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Item.SmallIcon = 5<br />
Case REG_FULL_RESOURCE_DESCRIPTOR<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Resource Descriptors require a special<br />
&#8216;   editor to properly be displayed or<br />
&#8216;   edited.<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Item.SmallIcon = 5<br />
rgeValue = &#8220;REG_FULL_RESOURCE_DESCRIPTOR&#8221;</p>
<p>Case REG_DWORD<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; REG_DWORD values are 32-bit unsigned<br />
&#8216;   integers<br />
&#8216; Tortuous manipulation to make values<br />
&#8216;   above 7FFFFFFF appear as positive<br />
&#8216;   values.<br />
&#8216; VB Longs would display them as<br />
&#8216;   negative numbers.<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Item.SmallIcon = 5<br />
fTempDbl = Asc(Mid$(rgeValue, 1, 1)) + &amp;H100&amp; * Asc(Mid$(rgeValue, 2, 1)) + &amp;H10000 * Asc(Mid$(rgeValue, 3, 1)) + &amp;H1000000 * CDbl(Asc(Mid$(rgeValue, 4, 1)))<br />
If fTempDbl &gt; &amp;H7FFFFFFF Then<br />
rgeValue = &#8220;&amp;H&#8221; &amp; Hex$(fTempDbl - 4294967296#)<br />
Else<br />
rgeValue = &#8220;&amp;H&#8221; &amp; Hex$(fTempDbl)<br />
End If<br />
rgeValue = rgeValue &amp; &#8221; (&#8221; &amp; Format$(fTempDbl) &amp; &#8220;)&#8221;</p>
<p>Case REG_BINARY</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Binary values may be of any length,<br />
&#8216;   and may represent text or other data.<br />
&#8216; They require a special editor to<br />
&#8216;   modify them.<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Item.SmallIcon = 5<br />
For iTempInt = 1 To Len(rgeValue)<br />
sBinaryString = sBinaryString &amp; Format$(Hex(Asc(Mid$(rgeValue, iTempInt, 1))), &#8220;00&#8243;) &amp; &#8221; &#8220;<br />
Next iTempInt<br />
rgeValue = sBinaryString<br />
End Select</p>
<p>If Len(rgeValue) = 0 Then<br />
rgeValue = &#8220;(value not set)&#8221;<br />
End If</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Enter the value into the list box<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Item.Text = rgeEntry<br />
Item.SubItems(1) = rgeValue<br />
Item.Tag = CStr(lKeyIndx)<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Increment the key and do it again.<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lKeyIndx = lKeyIndx + 1</p>
<p>ElseIf lRtn = ERROR_MORE_DATA Then<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; This error means that, despite querying the key,<br />
&#8216;   we have not set one of the buffers large<br />
&#8216;   enough.  Increment the buffer sizes and try<br />
&#8216;   again<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lMaxValueData = lMaxValueData + 5<br />
lMaxValueName = lMaxValueName + 5<br />
GoTo ReTryValueEnumeration</p>
<p>ElseIf lRtn = ERROR_NO_MORE_ITEMS Then<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Not an error, just end of list &#8212; exit the<br />
&#8216;   loop<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lRtn = ERROR_SUCCESS<br />
Exit Do</p>
<p>Else<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Key still open, so display the error and fall<br />
&#8216;   thru to the close function below<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
MsgBox RtnRegError(lRtn)<br />
Exit Do<br />
End If<br />
Loop</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Always close opened keys!<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lRtn = RegCloseKey(hKey)</p>
<p>End Sub</p>
<p>Function RegGetValue$()<br />
&#8216; This function is not used in this demo, but is a sample for<br />
&#8216; retrieving a single value<br />
&#8216; rgeMainKey must be one of the Publicly declared HKEY constants.<br />
Dim sKeyType&amp;       &#8216;returns the key type.  This function expects REG_SZ or REG_DWORD<br />
Dim ret&amp;            &#8216;returned by registry functions, should be 0&amp;<br />
Dim lpHKey&amp;         &#8216;return handle to opened key<br />
Dim lpcbData&amp;       &#8216;length of data in returned string<br />
Dim ReturnedString$ &#8216;returned string rgeValue<br />
Dim fTempDbl!<br />
If rgeMainKey &gt;= &amp;H80000000 And rgeMainKey &lt;= &amp;H80000006 Then<br />
&#8216; Open key<br />
ret = RegOpenKeyEx(rgeMainKey, rgeSubKey, 0&amp;, KEY_READ, lpHKey)<br />
If ret &lt;&gt; ERROR_SUCCESS Then<br />
RegGetValue = &#8220;&#8221;<br />
Exit Function     &#8216;No key open, so leave<br />
End If</p>
<p>&#8216; Set up buffer for data to be returned in.<br />
&#8216; Adjust next rgeValue for larger buffers.<br />
lpcbData = 255<br />
ReturnedString = Space$(lpcbData)</p>
<p>&#8216; Read key<br />
ret&amp; = RegQueryValueEx(lpHKey, rgeValue, ByVal 0&amp;, sKeyType, ReturnedString, lpcbData)<br />
If ret &lt;&gt; ERROR_SUCCESS Then<br />
RegGetValue = &#8220;&#8221;   &#8216;Key still open, so finish up<br />
Else<br />
If sKeyType = REG_DWORD Then<br />
fTempDbl = Asc(Mid$(ReturnedString, 1, 1)) + &amp;H100&amp; * Asc(Mid$(ReturnedString, 2, 1)) + &amp;H10000 * Asc(Mid$(ReturnedString, 3, 1)) + &amp;H1000000 * CDbl(Asc(Mid$(ReturnedString, 4, 1)))<br />
ReturnedString = Format$(fTempDbl, &#8220;000&#8243;)<br />
End If<br />
RegGetValue = Left$(ReturnedString, lpcbData - 1)<br />
End If<br />
&#8216; Always close opened keys.<br />
ret = RegCloseKey(lpHKey)<br />
End If<br />
End Function</p>
<p>Sub RegSetValue()<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; DWORD Values must be in Hex form for this function to<br />
&#8216;   work.<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Dim lRtn&amp;            &#8216;returned by registry functions, should be 0&amp;<br />
Dim hKey&amp;         &#8216;return handle to opened key<br />
Dim iFirstChar%<br />
Dim iSecondChar%<br />
Dim iThirdChar%<br />
Dim iFourthChar%<br />
Dim lpDisp&amp;</p>
<p>If rgeDataType &lt;&gt; REG_SZ And rgeDataType &lt;&gt; REG_DWORD Then<br />
MsgBox &#8220;This demo only supports writing keys of the types REG_SZ and REG_DWORD.  This key uses a different type.&#8221;<br />
Exit Sub<br />
End If</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Check rgeMainKey for validity<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
If rgeMainKey &gt;= &amp;H80000000 And rgeMainKey &lt;= &amp;H80000006 Then</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Open key<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lRtn = RegCreateKeyEx(rgeMainKey, rgeSubKey, 0&amp;, &#8220;&#8221;, 0&amp;, KEY_WRITE, 0&amp;, hKey, lpDisp)<br />
If lRtn &lt;&gt; ERROR_SUCCESS Then<br />
MsgBox RtnRegError(lRtn)<br />
rgeClear<br />
Exit Sub       &#8216;No key open, so leave<br />
End If</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Write new rgeValue to key<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
If rgeDataType = REG_DWORD Then<br />
rgeValue = Left(Trim(rgeValue), <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /><br />
If Left$(rgeValue, 2) &lt;&gt; &#8220;&amp;H&#8221; Then<br />
rgeValue = &#8220;&amp;H&#8221; &amp; Left(Trim(rgeValue), <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /><br />
End If<br />
If Len(rgeValue) &lt;= 6 Then<br />
rgeValue = rgeValue &amp; &#8220;&amp;&#8221;<br />
End If</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;Convert number string to 32-bit DWORD and save:<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lRtn = RegSetValueEx(hKey, rgeEntry, 0&amp;, rgeDataType, CLng(Val(rgeValue)), 4&#038;amp <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Else</p>
<p>&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;Save type REG_SZ (strings)<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lRtn = RegSetValueEx(hKey, rgeEntry, 0&amp;, rgeDataType, ByVal rgeValue, CLng(Len(rgeValue)))<br />
End If<br />
If lRtn &lt;&gt; ERROR_SUCCESS Then<br />
MsgBox RtnRegError(lRtn) &#8216;Key still open, so finish up<br />
End If<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216; Always close opened keys!<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
lRtn = RegCloseKey(hKey)<br />
End If<br />
End Sub</p>
<p>Private Function RtnRegError$(errorcode&#038;amp <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Select Case errorcode<br />
Case 1009, 1015<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8216;We&#8217;re in trouble now<br />
&#8216; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
RtnRegError = &#8220;The Registry Database is corrupt!&#8221;<br />
Case 2, 1010<br />
RtnRegError = &#8220;Bad Key Name!&#8221;<br />
Case 1011<br />
RtnRegError = &#8220;Can&#8217;t Open Key&#8221;<br />
Case 4, 1012<br />
RtnRegError = &#8220;Can&#8217;t Read Key&#8221;<br />
Case 5<br />
RtnRegError = &#8220;Access to this key is denied.&#8221;<br />
Case 1013<br />
RtnRegError = &#8220;Can&#8217;t Write Key&#8221;<br />
Case 8, 14<br />
RtnRegError = &#8220;Out of memory&#8221;<br />
Case 87<br />
RtnRegError = &#8220;Invalid Parameter&#8221;<br />
Case 234<br />
RtnRegError = &#8220;Error - There is more data than the buffer can handle!&#8221;<br />
Case Else<br />
RtnRegError = &#8220;Undefined Key Error Code&#8221; &amp; Str$(errorcode) &amp; &#8220;!&#8221;<br />
End Select<br />
End Function</p>
<p>Function WordLo(lLongIn&#038;amp <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> As Integer<br />
If (lLongIn And &amp;HFFFF&#038;amp <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> &gt; &amp;H7FFF Then<br />
WordLo = (lLongIn And &amp;HFFFF&#038;amp <img src='http://s.wordpre