home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 Secrets / Secrets2.iso / Utility / Registry / RegChk / Source / regchk.Frm (.txt) next >
Encoding:
Visual Basic Form  |  1997-07-19  |  10.8 KB  |  311 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "RegChk  Freeware!"
  4.    ClientHeight    =   5130
  5.    ClientLeft      =   1440
  6.    ClientTop       =   1635
  7.    ClientWidth     =   6870
  8.    Height          =   5535
  9.    Left            =   1380
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5130
  12.    ScaleWidth      =   6870
  13.    Top             =   1290
  14.    Width           =   6990
  15.    Begin VB.TextBox Activity 
  16.       Height          =   375
  17.       Left            =   240
  18.       TabIndex        =   4
  19.       Text            =   "Activity Indicator"
  20.       Top             =   120
  21.       Width           =   6255
  22.    End
  23.    Begin VB.CommandButton Done 
  24.       Caption         =   "About"
  25.       Default         =   -1  'True
  26.       Height          =   375
  27.       Left            =   1800
  28.       TabIndex        =   3
  29.       Top             =   4680
  30.       Width           =   855
  31.    End
  32.    Begin VB.DriveListBox DriveSelect 
  33.       Height          =   315
  34.       Left            =   2880
  35.       TabIndex        =   2
  36.       Top             =   4680
  37.       Width           =   3735
  38.    End
  39.    Begin VB.CommandButton RegChk 
  40.       Caption         =   "Start RegChk"
  41.       Height          =   375
  42.       Left            =   240
  43.       TabIndex        =   1
  44.       Top             =   4680
  45.       Width           =   1335
  46.    End
  47.    Begin VB.TextBox console 
  48.       Height          =   3735
  49.       Left            =   240
  50.       MultiLine       =   -1  'True
  51.       ScrollBars      =   2  'Vertical
  52.       TabIndex        =   0
  53.       Text            =   "regchk.frx":0000
  54.       Top             =   720
  55.       Width           =   6375
  56.    End
  57. Attribute VB_Name = "Form1"
  58. Attribute VB_Creatable = False
  59. Attribute VB_Exposed = False
  60. Static Sub cprint(dta$)
  61.    Dim Nd, i
  62.    Dim TempStr$
  63.    Dim lcl$
  64.    'protect users data passed by reference
  65.    lcl$ = dta$ + Chr$(13)
  66.    'Make sure the existing text doesn't get too large.
  67.    Nd = Len(console.Text)
  68.    If Nd >= 10000 Then
  69.      console.Text = Mid$(console.Text, 8000)
  70.      Nd = Len(console.Text)
  71.    End If
  72.    'Point to the end of console's data
  73.    console.SelStart = Nd
  74.    'Eliminate Line Feeds (put back below)
  75.    Do
  76.      i = InStr(lcl$, Chr$(10))
  77.      If i Then
  78.         lcl$ = Left$(lcl$, i - 1) + Mid$(lcl$, i + 1)
  79.      End If
  80.    Loop While i
  81.    'Make sure all CRs have LFs
  82.    i = 1
  83.    Do
  84.      i = InStr(i, lcl$, Chr$(13))
  85.      If i Then
  86.         lcl$ = Left$(lcl$, i) + Chr$(10) + Mid$(lcl$, i + 1)
  87.         i = i + 1
  88.      End If
  89.    Loop While i
  90.    '--- Add the filtered data to .Text
  91.    console.SelText = lcl$
  92. End Sub
  93. Sub trimby(x$, s$)
  94.    sep = InStr(x$, s$)
  95.    If sep Then
  96.       x$ = Mid$(x$, 1, sep - 1)
  97.    End If
  98. End Sub
  99. Sub whizzer(a%)
  100.    For qqq = 1 To a%
  101.       DoEvents
  102.     Next qqq
  103. End Sub
  104. Private Sub Done_Click()
  105.    If UCase$(Done.Caption) = "ABOUT" Then
  106.       console.Text = ""
  107.       Sleep 500
  108.       DoEvents
  109.       
  110.       Activity.Text = "RegChk: Who Why What and Warnings!"
  111.       
  112.       'need a monospaced font
  113.       fontsave$ = console.Font
  114.       console.Font = "Courier New"
  115.       
  116.       cprint "Written By:  Ron Thompson"
  117.       cprint "Email:       rdthom@netcom.com"
  118.       cprint "Language:    vb4"
  119.       cprint "System:      Win95"
  120.       cprint "Date:        July 19, 1997"
  121.       cprint "Version      1.0.1"
  122.       cprint "Status:      freeware"
  123.       cprint "Copyright:   Ron Thompson, 1997"
  124.       cprint ""
  125.       cprint ""
  126.       cprint "Why I wrote this"
  127.       cprint "--- - ----- ----"
  128.       cprint "RegChk was written so I could find the 'junk' in the registry. After installing and uninstalling several hundred programs, I knew that there must be lots of stuff in the registry that pointed to files that moved or were no longer on the harddrive."
  129.       cprint ""
  130.       cprint "There are many utilities, many articles written, and many commercial products dedicated to removing a specific app from the registry. I could find nothing that took the registry point-of-view to tell you what was moved or gone from the harddrive."
  131.       cprint ""
  132.       cprint "Now something does."
  133.       cprint ""
  134.       cprint ""
  135.       cprint "What does it do?"
  136.       cprint "---- ---- -- ---"
  137.       cprint "RegChk scans the registry for files and directories and checks to see if they exist. RegChk does NOTHING to the registry. It simply shells 'regedit.exe /e regchk.txt' which exports everything from the registry to a text file. Even the text file is treated as read-only (now you have that all-important registry backup you've been meaning to do). A separate report is generated for each drive."
  138.       cprint ""
  139.       cprint ""
  140.       cprint "What info do I get?"
  141.       cprint "---- ---- -- - ----"
  142.       cprint "Each missing file is reported in regchk_*.out where * is the drive letter you checked.  Each reported file has 3 lines of data similar to the following:"
  143.       cprint ""
  144.       cprint "D:\COREL\OFFICE7\QUATTRO7\QPW.EXE"
  145.       cprint "[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.WB1\shell\open\command]"
  146.       cprint "@=" + Chr$(34) + "D:\\COREL\\OFFICE7\\QUATTRO7\\QPW.EXE %1" + Chr$(34)
  147.       cprint ""
  148.       cprint "Line one is the actual filename or directory name that RegChk checked for existence.  Failure to find it is what caused this report entry to be generated. It may find some 'funny' things, because filename parsing from the registry is not an exact science. I'm constantly adding filters to eliminate the 'funny' ones from the scan. (If you find a 'funny', email it to me, I'll add it to the filter and email you the new code)"
  149.       cprint ""
  150.       cprint "Line two is the key I found just before the file or directory. It MAY NOT BE THE EXACT KEY, but will be *very* close to the problem."
  151.       cprint ""
  152.       cprint "Line three is the raw data in which I found the filename. It's for reference in case the filename looks 'funny'"
  153.       cprint ""
  154.       cprint ""
  155.       cprint "What do I do with it?"
  156.       cprint "---- -- - -- ---- ---"
  157.       cprint "You can use this information to edit your registry. THIS CAN BE A VERY DANGEROUS THING TO DO. If you're not comfortable in the registry, stay out, and just forget you ever saw this program. MISTAKES IN REGISTRY EDITS CAN EASILY DESTROY ALL THE DATA ON YOUR SYSTEM, AND PERHAPS ON OTHER SYSTEMS AS WELL. YOU HAVE BEEN WARNED."
  158.       cprint ""
  159.       cprint "That said, use the information to delete data and keys for files and directories that no longer exist on your system. Use your own discretion in deleting references."
  160.       cprint ""
  161.       
  162.       'reposition the About at the top
  163.       console.SelStart = 1
  164.       
  165.       'we did the About, now disable it
  166.       Done.Enabled = False
  167.       Done.Caption = "Stop!"
  168.       
  169.       Exit Sub
  170.    End If
  171. exitstate% = 1
  172. End Sub
  173. Private Sub DriveSelect_Change()
  174.    drvltr$ = Mid$(DriveSelect.List(DriveSelect.ListIndex), 1, 1)
  175.    Activity.Text = "Current output file will be named regchk_" + drvltr$ + ".out"
  176. End Sub
  177. Private Sub Form_Paint()
  178.    drvltr$ = Mid$(DriveSelect.List(DriveSelect.ListIndex), 1, 1)
  179.    Activity.Text = "Current output file will be named regchk_" + drvltr$ + ".out"
  180. End Sub
  181. Private Sub RegChk_Click()
  182. 'registry directory verification routine
  183. 'turn off the run button
  184. RegChk.Enabled = False
  185. 'change the About to Stop! and disable
  186. Done.Caption = "Stop!"
  187. Done.Enabled = False
  188. 'set up the console font as proportional spaced
  189. console.Font = "MS Sans Serif"
  190. 'clear console and inform user of process
  191. console.Text = ""
  192. Sleep 500
  193. DoEvents
  194. cprint "Exporting registry.  This may take a couple of minutes, please wait..."
  195. Sleep 1000
  196. DoEvents
  197. 'get which drive is selected
  198. chkdrv$ = Mid$(DriveSelect.List(DriveSelect.ListIndex), 1, 2) + "\"
  199. drvltr$ = Mid$(chkdrv$, 1, 1)
  200. 'export everything in the registry
  201. Shell "regedit /e .\regchk.txt"
  202. 'let user know it's done
  203. console.Text = ""
  204. Sleep 1000
  205. DoEvents
  206. cprint "Export complete, now checking files and directories on " + UCase$(chkdrv$)
  207. cprint ""
  208. Sleep 1000
  209. DoEvents
  210. Sleep 1000
  211. DoEvents
  212. Sleep 1000
  213. DoEvents
  214. 'enable the Done button
  215. Done.Enabled = True
  216. 'open up the exported file and the output file
  217. Open ".\regchk.txt" For Input As #1
  218. Open ".\regchk_" + drvltr$ + ".out" For Output As #2
  219. 'start reading the file and checking dirs/files
  220.    Line Input #1, a$
  221.    raw$ = a$
  222.    'save the section headers for the output file
  223.    If Mid$(a$, 1, 1) = "[" Then
  224.       section$ = a$
  225.    End If
  226.    'see if theres a drive letter  C:\
  227.    drv = InStr(UCase(a$), UCase$(chkdrv$))
  228.    If drv Then
  229.       
  230.       'strip off everything before the drive letter
  231.       a$ = Mid$(a$, drv)
  232.       
  233.       'now parse for righttrim characters
  234.       trimby a$, Chr$(34)  'double quote
  235.       trimby a$, ","       'comma
  236.       trimby a$, "|"       'pipe
  237.       trimby a$, ";"       'semi-colon
  238.       trimby a$, "%"       'percent
  239.       trimby a$, "/"       'forward slash
  240.       trimby a$, ">"       'greater than
  241.       trimby a$, "^"       'upcaret
  242.       trimby a$, "-"       'minus
  243.       trimby a$, "]"       'right bracket
  244.       trimby a$, " \"      'space and backslash
  245.       
  246.       'convert all \\ to single \
  247.       For i = 1 To Len(a$)
  248.          slash = InStr(a$, "\\")
  249.          If slash Then
  250.             a$ = Mid$(a$, 1, slash) + Mid$(a$, slash + 2)
  251.          End If
  252.       Next i
  253.       
  254.       'activity indicator
  255.       Activity.Text = a$
  256.       
  257.       'clear the found flag, then look
  258.       found = 0
  259.       
  260.       'see if its a "normal" file
  261.       If Dir(a$) <> "" Then found = 1
  262.       
  263.       'see if its a "hidden" file
  264.       If Dir(a$, 2) <> "" Then found = 1
  265.       
  266.       'see if its a "system" file
  267.       If Dir(a$, 4) <> "" Then found = 1
  268.       
  269.       'or a directory
  270.       If Dir(a$, 16) <> "" Then found = 1
  271.       
  272.       'didn't find it, report to user
  273.       If found = 0 Then
  274.          cprint a$
  275.          Print #2, a$
  276.          Print #2, section$
  277.          Print #2, raw$
  278.          Print #2, ""
  279.       End If
  280.       
  281.    End If
  282.    'see if user would like to stop
  283.    If exitstate% = 1 Then Exit Do
  284.    'play nice with windows
  285.    DoEvents
  286. Loop While Not EOF(1)
  287. If exitstate% = 0 Then
  288.    cprint ""
  289.    cprint "Scan complete"
  290.    Activity.Text = "Scan complete"
  291.    cprint ""
  292.    cprint "User interrupted, scan not complete"
  293.    Activity.Text = "User interrupted, scan not complete"
  294. End If
  295. 'indicate what the stop/exit button does now
  296. Done.Caption = "Exit"
  297. 'turn on the run button
  298. RegChk.Enabled = True
  299. cprint ""
  300. cprint ""
  301. cprint "regchk_" + drvltr$ + ".out contains more information"
  302. cprint ""
  303. cprint "Use the scroll bars to review the files and directories"
  304. cprint "click Exit after review"
  305. 'hang around till user clicks
  306. exitstate% = 0
  307.    DoEvents
  308.    If exitstate% = 1 Then Exit Do
  309. Close
  310. End Sub
  311.