home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 4_2005-2006.ISO / data / Zips / UPX_FrontE1944871112005.psc / frmMain.frm < prev    next >
Text File  |  2005-11-01  |  22KB  |  681 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
  3. Begin VB.Form frmMain 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "UPX (Ultimate Packer for eXecutables) FrontEnd v"
  6.    ClientHeight    =   5775
  7.    ClientLeft      =   45
  8.    ClientTop       =   435
  9.    ClientWidth     =   7860
  10.    BeginProperty Font 
  11.       Name            =   "Tahoma"
  12.       Size            =   8.25
  13.       Charset         =   0
  14.       Weight          =   400
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    LinkTopic       =   "Form1"
  20.    MaxButton       =   0   'False
  21.    MinButton       =   0   'False
  22.    ScaleHeight     =   5775
  23.    ScaleWidth      =   7860
  24.    StartUpPosition =   2  'CenterScreen
  25.    Begin VB.TextBox Text1 
  26.       Height          =   795
  27.       Left            =   3060
  28.       MultiLine       =   -1  'True
  29.       ScrollBars      =   3  'Both
  30.       TabIndex        =   24
  31.       Top             =   5970
  32.       Visible         =   0   'False
  33.       Width           =   915
  34.    End
  35.    Begin VB.Frame Frame4 
  36.       Caption         =   "Command Function:"
  37.       Height          =   2685
  38.       Left            =   90
  39.       TabIndex        =   9
  40.       Top             =   2970
  41.       Width           =   7665
  42.       Begin MSComctlLib.ListView ListView1 
  43.          Height          =   2235
  44.          Left            =   270
  45.          TabIndex        =   21
  46.          Top             =   270
  47.          Width           =   7125
  48.          _ExtentX        =   12568
  49.          _ExtentY        =   3942
  50.          View            =   3
  51.          LabelWrap       =   -1  'True
  52.          HideSelection   =   -1  'True
  53.          _Version        =   393217
  54.          ForeColor       =   -2147483640
  55.          BackColor       =   -2147483643
  56.          BorderStyle     =   1
  57.          Appearance      =   1
  58.          NumItems        =   5
  59.          BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  60.             Text            =   "Filename"
  61.             Object.Width           =   2822
  62.          EndProperty
  63.          BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  64.             SubItemIndex    =   1
  65.             Text            =   "Size"
  66.             Object.Width           =   2469
  67.          EndProperty
  68.          BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  69.             SubItemIndex    =   2
  70.             Text            =   "Packed"
  71.             Object.Width           =   2469
  72.          EndProperty
  73.          BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  74.             SubItemIndex    =   3
  75.             Text            =   "Ratio"
  76.             Object.Width           =   1411
  77.          EndProperty
  78.          BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  79.             SubItemIndex    =   4
  80.             Text            =   "Status"
  81.             Object.Width           =   2822
  82.          EndProperty
  83.       End
  84.    End
  85.    Begin VB.Frame Frame3 
  86.       Caption         =   "Command Function:"
  87.       Height          =   1965
  88.       Left            =   4020
  89.       TabIndex        =   8
  90.       Top             =   990
  91.       Width           =   3735
  92.       Begin VB.CheckBox ckBackup 
  93.          Caption         =   "Keep backup files"
  94.          Height          =   195
  95.          Left            =   300
  96.          TabIndex        =   22
  97.          ToolTipText     =   "Backup as Filename.ex~"
  98.          Top             =   900
  99.          Width           =   1635
  100.       End
  101.       Begin VB.CommandButton cmdDecompress 
  102.          Caption         =   "Decompress"
  103.          Height          =   345
  104.          Left            =   2370
  105.          TabIndex        =   14
  106.          Top             =   1320
  107.          Width           =   1095
  108.       End
  109.       Begin VB.CommandButton cmdCompress 
  110.          Caption         =   "Compress"
  111.          Height          =   345
  112.          Left            =   2370
  113.          TabIndex        =   13
  114.          Top             =   840
  115.          Width           =   1095
  116.       End
  117.       Begin VB.HScrollBar HScroll1 
  118.          Height          =   255
  119.          Left            =   1770
  120.          Max             =   9
  121.          Min             =   1
  122.          TabIndex        =   12
  123.          Top             =   390
  124.          Value           =   1
  125.          Width           =   1155
  126.       End
  127.       Begin VB.CheckBox ckOverwrite 
  128.          Caption         =   "Overwrite exist files"
  129.          Height          =   225
  130.          Left            =   300
  131.          TabIndex        =   11
  132.          Top             =   1380
  133.          Width           =   1965
  134.       End
  135.       Begin VB.TextBox txtQuality 
  136.          Height          =   285
  137.          Left            =   750
  138.          MaxLength       =   1
  139.          TabIndex        =   10
  140.          Text            =   "1"
  141.          Top             =   390
  142.          Width           =   375
  143.       End
  144.       Begin VB.Label Label4 
  145.          Caption         =   "Better"
  146.          Height          =   225
  147.          Left            =   3030
  148.          TabIndex        =   17
  149.          Top             =   420
  150.          Width           =   495
  151.       End
  152.       Begin VB.Label lblQuality 
  153.          Caption         =   "Quality:"
  154.          Height          =   225
  155.          Left            =   120
  156.          TabIndex        =   16
  157.          Top             =   420
  158.          Width           =   825
  159.       End
  160.       Begin VB.Label Label3 
  161.          Caption         =   "Faster"
  162.          Height          =   255
  163.          Left            =   1260
  164.          TabIndex        =   15
  165.          Top             =   420
  166.          Width           =   585
  167.       End
  168.    End
  169.    Begin VB.CommandButton cmdAdd 
  170.       Caption         =   "Add..."
  171.       Height          =   345
  172.       Left            =   2730
  173.       TabIndex        =   3
  174.       Top             =   1350
  175.       Width           =   1095
  176.    End
  177.    Begin VB.CommandButton cmdClearAll 
  178.       Caption         =   "Clear All"
  179.       Height          =   345
  180.       Left            =   2730
  181.       TabIndex        =   7
  182.       Top             =   2310
  183.       Width           =   1095
  184.    End
  185.    Begin VB.Frame Frame2 
  186.       Caption         =   "Execute Files"
  187.       Height          =   1965
  188.       Left            =   90
  189.       TabIndex        =   5
  190.       Top             =   990
  191.       Width           =   3885
  192.       Begin VB.CommandButton cmdDelete 
  193.          Caption         =   "Delete"
  194.          Height          =   345
  195.          Left            =   2640
  196.          TabIndex        =   18
  197.          Top             =   810
  198.          Width           =   1095
  199.       End
  200.       Begin VB.ListBox List1 
  201.          Height          =   1425
  202.          Left            =   120
  203.          MultiSelect     =   2  'Extended
  204.          TabIndex        =   6
  205.          Top             =   330
  206.          Width           =   2385
  207.       End
  208.    End
  209.    Begin VB.ListBox lstFiles 
  210.       Height          =   645
  211.       Left            =   4380
  212.       TabIndex        =   4
  213.       Top             =   5940
  214.       Width           =   1335
  215.    End
  216.    Begin VB.Frame Frame1 
  217.       Height          =   915
  218.       Left            =   90
  219.       TabIndex        =   0
  220.       Top             =   60
  221.       Width           =   7665
  222.       Begin VB.CommandButton cmdBrowse 
  223.          Caption         =   "..."
  224.          Height          =   345
  225.          Left            =   4950
  226.          TabIndex        =   20
  227.          Top             =   330
  228.          Width           =   300
  229.       End
  230.       Begin VB.CommandButton cmdHelp 
  231.          Caption         =   "Help"
  232.          Height          =   345
  233.          Left            =   5340
  234.          TabIndex        =   19
  235.          Top             =   330
  236.          Width           =   1095
  237.       End
  238.       Begin VB.TextBox txtOutputDir 
  239.          Height          =   345
  240.          Left            =   1380
  241.          Locked          =   -1  'True
  242.          TabIndex        =   2
  243.          Top             =   330
  244.          Width           =   3465
  245.       End
  246.       Begin VB.Label Label1 
  247.          Caption         =   "TSHsoft"
  248.          BeginProperty Font 
  249.             Name            =   "Tahoma"
  250.             Size            =   12
  251.             Charset         =   0
  252.             Weight          =   700
  253.             Underline       =   0   'False
  254.             Italic          =   -1  'True
  255.             Strikethrough   =   0   'False
  256.          EndProperty
  257.          Height          =   375
  258.          Left            =   6510
  259.          TabIndex        =   23
  260.          Top             =   330
  261.          Width           =   1065
  262.       End
  263.       Begin VB.Label Label2 
  264.          Caption         =   "Output Folder:"
  265.          Height          =   225
  266.          Left            =   180
  267.          TabIndex        =   1
  268.          Top             =   390
  269.          Width           =   1155
  270.       End
  271.    End
  272.    Begin UPXFE.ReadOutput ReadOutput1 
  273.       Left            =   6240
  274.       Top             =   5910
  275.       _ExtentX        =   1720
  276.       _ExtentY        =   1296
  277.    End
  278. End
  279. Attribute VB_Name = "frmMain"
  280. Attribute VB_GlobalNameSpace = False
  281. Attribute VB_Creatable = False
  282. Attribute VB_PredeclaredId = True
  283. Attribute VB_Exposed = False
  284. 'The Ultimate Packer for eXecutables FrontEnd
  285. 'UPX FrontEnd v0.10 31/10/2005
  286. 'Copyright (C) 2005 by TSHsoft
  287. 'Internal Dos program UPX v1.25
  288.  
  289. Option Explicit
  290. Private c As cFileDialog
  291. Dim strOutput As String
  292. Dim Temp(6) As String 'Output data(status)
  293.  
  294.  
  295. Private Sub cmdBrowse_Click()
  296. Dim strResFolder As String
  297.  
  298. strResFolder = BrowseForFolder(hwnd, "Please select a folder.")
  299.  
  300. If strResFolder <> "" Then
  301.    txtOutputDir.Text = strResFolder
  302. End If
  303. End Sub
  304.  
  305. Private Sub cmdHelp_Click()
  306.   frmHelp.Show
  307. End Sub
  308.  
  309. Private Sub cmdAdd_Click()
  310. On Error GoTo cmdClassError
  311. Dim sFiles() As String
  312. Dim filecount As Long
  313. Dim sDir As String
  314. Dim i As Long
  315.     
  316.     With c
  317.         .DialogTitle = "Choose Executable Files"
  318.         .CancelError = False
  319.         .Filename = "" 'clear
  320.         .hwnd = Me.hwnd
  321.         .flags = OFN_EXPLORER Or OFN_FILEMUSTEXIST Or OFN_ALLOWMULTISELECT
  322.         .InitDir = App.Path
  323.         .Filter = "Executable Files (*.exe)|*.exe"
  324.         .FilterIndex = 1
  325.         .ShowOpen
  326.  
  327.         If .Filename = "" Then Exit Sub
  328.         .ParseMultiFileName sDir, sFiles(), filecount
  329.         If UBound(sFiles) = 0 Then
  330.            List1.AddItem sFiles(0)
  331.            lstFiles.AddItem .Filename
  332.         Else
  333.            For i = 0 To filecount - 1
  334.                If Mid(sDir, Len(sDir), 1) <> "\" Then
  335.                   lstFiles.AddItem sDir & "\" & sFiles(i)
  336.                Else
  337.                   lstFiles.AddItem sDir & sFiles(i)
  338.                End If
  339.                List1.AddItem sFiles(i)
  340.            Next i
  341.         End If
  342.     End With
  343.     
  344. Exit Sub
  345.  
  346. cmdClassError:
  347.     If (Err.Number <> 20001) Then
  348.         MsgBox "Error: " & Err.Description, vbCritical, "Add"
  349.     End If
  350.     
  351. End Sub
  352.  
  353. Private Sub cmdClearAll_Click()
  354.   lstFiles.Clear
  355.   List1.Clear
  356.   Text1.Text = ""
  357. End Sub
  358.  
  359. Private Sub cmdCompress_Click()
  360. On Error GoTo errHandler
  361. Dim strCommand, strOption As String
  362. Dim strRun, sOutput, TMP As String
  363. Dim i, j, n As Integer
  364.   
  365.   strCommand = ""
  366.   strCommand = "-" & txtQuality.Text & " "
  367.   strOption = ""
  368.   
  369.   If ckOverwrite.Value = 1 Then
  370.      strOption = "-f "
  371.   End If
  372.   
  373.   If Right(txtOutputDir.Text, 1) <> "\" Then
  374.        sOutput = txtOutputDir.Text & "\"
  375.     Else
  376.        sOutput = txtOutputDir.Text
  377.     End If
  378.     
  379.   'if upx.exe not found
  380.   If FileExists(cPath & "upx.exe") = False Then
  381.      MsgBox "upx.exe not found!", vbExclamation, "Compress"
  382.   Else
  383.   'if upx.exe found
  384.      ListView1.ListItems.Clear
  385.      ListView1.ColumnHeaders(3).Text = "Packed"
  386.      Me.MousePointer = 11 'busy
  387.      For i = 0 To List1.ListCount - 1
  388.          strRun = "upx " & strCommand & strOption & "-o " & Chr(34) & _
  389.                   sOutput & List1.List(i) & Chr(34) & Chr(32) _
  390.                   & Chr(34) & lstFiles.List(i) & Chr(34)
  391.          
  392.          If ckBackup.Value = 1 Then
  393.             If FileExists(sOutput & List1.List(i)) Then
  394.                FileCopy sOutput & List1.List(i), Mid(sOutput & List1.List(i), 1, Len(sOutput & List1.List(i)) - 1) & "~"
  395.             End If
  396.          End If
  397.          
  398.          'compressing...
  399.          Text1.Text = "" 'clear
  400.          ReadOutput1.SetCommand = strRun
  401.          ReadOutput1.ProcessCommand
  402.          DoEvents
  403.          j = InStrRev(Text1, "upx:")
  404.          If j = 0 Then 'if j=0 mean not found error.
  405.             TMP = Mid(Text1, 327, Len(Text1) - 327)
  406.             n = StringTokenizer(Trim(TMP) & " ")
  407.             For n = 1 To (n / 6)
  408.                 With ListView1.ListItems
  409.                 .Add(n).Text = Mid(Temp(6 * n), 1, Len(Temp(6 * n)) - 6) 'Filename
  410.                 .item(n).SubItems(1) = FileByteFormat(CLng(Temp(6 * (n - 1) + 1))) 'Size
  411.                 .item(n).SubItems(2) = FileByteFormat(CLng(Temp(3 * (n + n - 1)))) 'Packed
  412.                 .item(n).SubItems(3) = Temp(3 * (n + n - 1) + 1) 'Ratio
  413.                 .item(n).SubItems(4) = "Done!" 'Status
  414.                 End With
  415.             Next n
  416.          Else
  417.             TMP = Mid(Text1, 327, Len(Text1) - 327)
  418.             j = InStrRev(TMP, "AlreadyPacked")
  419.             If j <> 0 Then
  420.                With ListView1.ListItems
  421.                 .Add(1).Text = List1.List(i) 'Filename
  422.                 .item(1).SubItems(1) = FileByteFormat(FileLen(lstFiles.List(i))) 'Size
  423.                 .item(1).SubItems(2) = "0" 'Packed
  424.                 .item(1).SubItems(3) = "0" 'Ratio
  425.                 .item(1).SubItems(4) = "Already Packed" 'Status
  426.                 End With
  427.             End If
  428.             j = InStrRev(TMP, "File exists")
  429.             If j <> 0 Then
  430.                With ListView1.ListItems
  431.                 .Add(1).Text = List1.List(i) 'Filename
  432.                 .item(1).SubItems(1) = FileByteFormat(FileLen(lstFiles.List(i))) 'Size
  433.                 .item(1).SubItems(2) = "0" 'Packed
  434.                 .item(1).SubItems(3) = "0" 'Ratio
  435.                 .item(1).SubItems(4) = "File exists" 'Status
  436.                 End With
  437.             End If
  438.             j = InStrRev(TMP, "Permission denied")
  439.             If j <> 0 Then
  440.                With ListView1.ListItems
  441.                 .Add(1).Text = List1.List(i) 'Filename
  442.                 .item(1).SubItems(1) = FileByteFormat(FileLen(lstFiles.List(i))) 'Size
  443.                 .item(1).SubItems(2) = "0" 'Packed
  444.                 .item(1).SubItems(3) = "0" 'Ratio
  445.                 .item(1).SubItems(4) = "Permission denied" 'Status
  446.                 End With
  447.             End If
  448.             
  449.          End If
  450.          
  451.      Next i
  452.      'Complete!
  453.      Me.MousePointer = 0 'default
  454.   End If
  455.   
  456. Exit Sub
  457. errHandler:
  458. MsgBox (Err.Description & " - " & Err.Source & " - " & CStr(Err.Number)), vbCritical, "Compress"
  459. End Sub
  460.  
  461. Private Sub cmdDecompress_Click()
  462. On Error GoTo errHandler
  463. Dim strCommand, strOption As String
  464. Dim strRun, sOutput, TMP As String
  465. Dim i, j, n As Integer
  466.   
  467.   strCommand = ""
  468.   strCommand = "-d "
  469.   strOption = ""
  470.   
  471.   If ckOverwrite.Value = 1 Then
  472.      strOption = "-f "
  473.   End If
  474.   
  475.   If Right(txtOutputDir.Text, 1) <> "\" Then
  476.      sOutput = txtOutputDir.Text & "\"
  477.   Else
  478.      sOutput = txtOutputDir.Text
  479.   End If
  480.     
  481.   'if upx.exe not found
  482.   If FileExists(cPath & "upx.exe") = False Then
  483.      MsgBox "upx.exe not found!", vbExclamation, "Decompress"
  484.   Else
  485.   'if upx.exe found
  486.      ListView1.ListItems.Clear
  487.      ListView1.ColumnHeaders(3).Text = "Unpacked"
  488.      Me.MousePointer = 11 'busy
  489.      For i = 0 To List1.ListCount - 1
  490.          strRun = "upx " & strCommand & strOption & "-o " & Chr(34) & _
  491.                   sOutput & List1.List(i) & Chr(34) & Chr(32) _
  492.                   & Chr(34) & lstFiles.List(i) & Chr(34)
  493.          
  494.          If ckBackup.Value = 1 Then
  495.             If FileExists(sOutput & List1.List(i)) Then
  496.                FileCopy sOutput & List1.List(i), Mid(sOutput & List1.List(i), 1, Len(sOutput & List1.List(i)) - 1) & "~"
  497.             End If
  498.          End If
  499.          
  500.          'decompressing...
  501.          Text1.Text = "" 'clear
  502.          ReadOutput1.SetCommand = strRun
  503.          ReadOutput1.ProcessCommand
  504.          DoEvents
  505.          
  506.          j = InStrRev(Text1, "upx:")
  507.          If j = 0 Then 'if j=0 mean not found error.
  508.             TMP = Mid(Text1, 327, Len(Text1) - 327)
  509.             n = StringTokenizer(Trim(TMP) & " ")
  510.             For n = 1 To (n / 6)
  511.                 With ListView1.ListItems
  512.                 .Add(n).Text = Mid(Temp(6 * n), 1, Len(Temp(6 * n)) - 8) 'Filename
  513.                 .item(n).SubItems(1) = FileByteFormat(CLng(Temp(3 * (n + n - 1)))) 'Size
  514.                 .item(n).SubItems(2) = FileByteFormat(CLng(Temp(6 * (n - 1) + 1))) 'Unpacked
  515.                 .item(n).SubItems(3) = Temp(3 * (n + n - 1) + 1) 'Ratio
  516.                 .item(n).SubItems(4) = "Done!" 'Status
  517.                 End With
  518.             Next n
  519.          Else
  520.             TMP = Mid(Text1, 327, Len(Text1) - 327)
  521.             j = InStrRev(TMP, "NotPacked")
  522.             If j <> 0 Then
  523.                With ListView1.ListItems
  524.                 .Add(1).Text = List1.List(i) 'Filename
  525.                 .item(1).SubItems(1) = FileByteFormat(FileLen(lstFiles.List(i))) 'Size
  526.                 .item(1).SubItems(2) = "0" 'Unpacked
  527.                 .item(1).SubItems(3) = "0" 'Ratio
  528.                 .item(1).SubItems(4) = "Not Packed" 'Status
  529.                 End With
  530.             End If
  531.             j = InStrRev(TMP, "File exists")
  532.             If j <> 0 Then
  533.                With ListView1.ListItems
  534.                 .Add(1).Text = List1.List(i) 'Filename
  535.                 .item(1).SubItems(1) = FileByteFormat(FileLen(lstFiles.List(i))) 'Size
  536.                 .item(1).SubItems(2) = "0" 'Unpacked
  537.                 .item(1).SubItems(3) = "0" 'Ratio
  538.                 .item(1).SubItems(4) = "File exists" 'Status
  539.                 End With
  540.             End If
  541.             j = InStrRev(TMP, "Permission denied")
  542.             If j <> 0 Then
  543.                With ListView1.ListItems
  544.                 .Add(1).Text = List1.List(i) 'Filename
  545.                 .item(1).SubItems(1) = FileByteFormat(FileLen(lstFiles.List(i))) 'Size
  546.                 .item(1).SubItems(2) = "0" 'Unpacked
  547.                 .item(1).SubItems(3) = "0" 'Ratio
  548.                 .item(1).SubItems(4) = "Permission denied" 'Status
  549.                 End With
  550.             End If
  551.             
  552.          End If
  553.          
  554.      Next i
  555.      'Complete!
  556.      Me.MousePointer = 0 'default
  557.   End If
  558.  
  559. Exit Sub
  560. errHandler:
  561. MsgBox (Err.Description & " - " & Err.Source & " - " & CStr(Err.Number)), vbCritical, "Decompress"
  562. End Sub
  563.  
  564. Private Sub cmdDelete_Click()
  565. Dim i As Integer
  566.  
  567.   If List1.ListCount = 0 Then
  568.      MsgBox "Please select executable files to delete.", vbExclamation, "Delete"
  569.   End If
  570.   
  571.   Do While i < List1.ListCount
  572.       If List1.Selected(i) = True Then
  573.          List1.RemoveItem i
  574.          lstFiles.RemoveItem i
  575.       Else
  576.          i = i + 1
  577.       End If
  578.       DoEvents
  579.   Loop
  580.   
  581. End Sub
  582.  
  583. Private Sub txtQuality_Change()
  584.   HScroll1.Value = txtQuality.Text
  585. End Sub
  586.  
  587. Private Sub txtQuality_KeyPress(KeyAscii As Integer)
  588.   'if input 1 to 9 or Backspace
  589. If KeyAscii >= 49 And KeyAscii <= 57 Or KeyAscii = 8 Then
  590.    Else
  591.    KeyAscii = 0
  592. End If
  593. End Sub
  594.  
  595. Private Sub HScroll1_Change()
  596.   txtQuality.Text = HScroll1.Value
  597. End Sub
  598.  
  599. Private Sub ReadOutput1_GotChunk(ByVal sChunk As String, ByVal LastChunk As Boolean)
  600.  
  601.  Text1 = Text1 & sChunk
  602.  
  603. End Sub
  604.  
  605. Private Sub ReadOutput1_Error(ByVal Error As String, LastDLLError As Long)
  606.     MsgBox "Error!" & vbNewLine & _
  607.             "Description: " & Error & vbNewLine & _
  608.             "LastDLLError: " & LastDLLError, vbCritical, "Error"
  609. End Sub
  610.  
  611. Private Sub Form_Load()
  612.  
  613.     Me.Caption = Me.Caption & App.Major & "." & App.Minor & App.Revision
  614.     Set c = New cFileDialog
  615.     
  616.     txtOutputDir.Text = App.Path
  617.     
  618.     'copy it to WINDOWS Directory, so can run it anyway!
  619.     If FileExists(Get_WinPath & "upx.exe") = False Then
  620.        If FileExists(cPath & "upx.exe") = True Then
  621.           FileCopy cPath & "upx.exe", Get_WinPath & "upx.exe"
  622.        Else
  623.           MsgBox "upx.exe not found! Please download at http://upx.sourceforge.net", vbInformation, "UPX FrontEnd"
  624.           End
  625.        End If
  626.     End If
  627.     
  628. End Sub
  629.  
  630. Private Sub Form_Unload(Cancel As Integer)
  631. Set c = Nothing
  632. End Sub
  633.  
  634. Function StringTokenizer(DATA As String) As Integer
  635. On Error Resume Next
  636. Dim i As Integer, j As Integer, t As Integer
  637. Dim S As String
  638.  
  639. j = 1 'set data count to zero
  640. t = 1 'set start to zero
  641.  
  642. For i = 1 To Len(DATA)
  643.     S = Mid$(DATA, i, 1)
  644.     If S = " " Then
  645.        If Trim(Mid$(DATA, t, i - t)) <> "" Then
  646.           Temp(j) = Trim(Mid$(DATA, t, i - t))
  647.           t = i + 1
  648.           j = j + 1
  649.        End If
  650.     End If
  651. Next i
  652.  
  653. StringTokenizer = j - 1
  654. End Function
  655.  
  656. Public Function FileByteFormat(FileBytes As Long) As String
  657. On Error Resume Next
  658. Dim nFileNum As Integer
  659. Dim TempNum As Single
  660.  
  661. If FileBytes > 0 Then
  662.     ' Get file's length
  663.     FileByteFormat = FileBytes / 1024
  664.     
  665.     ' Round number
  666.     TempNum = FileByteFormat - Int(FileByteFormat)
  667.     
  668.     ' Use different scale according to the size of the file
  669.     Select Case Val(FileByteFormat)
  670.         Case Is > 1024 ' Use Mega Byte
  671.             FileByteFormat = Format(FileByteFormat / 1000, "#.##MB")
  672.         Case Else  ' Use Kilo Byte
  673.             ' All values are to round up
  674.             FileByteFormat = Format(FileByteFormat + (1 - TempNum), "###KB")
  675.     End Select
  676. Else
  677.     FileByteFormat = "0KB"
  678. End If
  679.  
  680. End Function
  681.