home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / PVb5.0 / VB / SETUPKIT / SETUP1 / LOGGING.BAS < prev    next >
Encoding:
BASIC Source File  |  1997-01-31  |  9.9 KB  |  267 lines

  1. Attribute VB_Name = "basLogging"
  2. Option Explicit
  3. Option Compare Text
  4.  
  5. '
  6. ' ─ú┐Θ basLogging (╜÷ 32 ╬╗╣ª─▄)
  7. '
  8. '▒╛─ú┐Θ╓╨╡─╒Γ╕÷╫╙│╠╨≥╙├╙┌╡╟┬╝╙ª╙├│╠╨≥╔╛│²│╠╨≥╚╒╓╛╬─╝■╓╨╡─▓┘╫≈íó╛»╕µíó╠ß╩╛║═┤φ╬≤íú
  9. '╚τ╣√╙├╗º╛÷╢¿╔╛│²╥╤░▓╫░╡─╙ª╙├│╠╨≥(═¿╣²╘┌ Windows NT ╧┬╡─
  10. '│╠╨≥╣▄└φ╞≈═╝▒Ω╗≥╘┌ Windows 95 ╧┬┐╪╓╞├µ░σ╓╨╡─í░╠φ╝╙/╔╛│²│╠╨≥í▒═╝▒Ω)ú¼
  11. '╒Γ╕÷╚╒╓╛╬─╝■╜½╘┌╙ª╙├│╠╨≥╔╛│²╩╡╙├╣ñ╛▀ (ST5UNST.EXE) ╓╨╩╣╙├íú
  12. '
  13. '
  14. '▒╛║»╩²╗∙╙┌└α╦╞╙┌╩┬╬±╡─"▓┘╫≈"íú
  15. '╬▐┬█║╬╩▒ú¼░▓╫░│╠╨≥┐¬╩╝┤ª└φ╥╗╕÷╨┬▓┘╫≈(╥╗╕÷▓┘╫≈╩╟╙ª╙├│╠╨≥╔╛│²│╠╨≥
  16. '╩╡╙├╣ñ╛▀▒╪╨δ│╖╧√╡─▓╜╓Φ)ú¼
  17. '║»╩² NewAction() ╬¬╒Γ╕÷▓┘╫≈▒╪╨δ╙├╒²╚╖╡─▓╬╩²╡≈╙├
  18. '(╘┌╒Γ╕÷╣ñ│╠╓╨╦╤╦≈ NewActionú¼▓Θ┐┤╚τ║╬╬¬▓╗═¼╡─▓┘╫≈╨╬│╔▓╬╩²)íú
  19. '╡▒▓┘╫≈╥╤▒╗│╔╣ª╡╪═Ω│╔ú¼╡≈╙├║»╩² CommitAction()ú¼╗≥╒▀ú¼
  20. '╚τ╣√╬┤│╔╣ª╡╪═Ω│╔▓┘╫≈ú¼▒╪╨δ╡≈╙├ AbortAction()íú
  21. '╚τ╣√╡≈╙├┴╦ CommitAction()ú¼╕├▓┘╫≈╘┌─╟╥╗╡π▒╗╡╟┬╝ú¼
  22. '╢°╟╥╙ª╙├│╠╨≥╔╛│²╩╡╙├╣ñ╛▀╜½│╖╧√╕├▓┘╫≈
  23. '(└²╚τú¼╔╛│²╙╔░▓╫░│╠╨≥╕┤╓╞╡─╬─╝■)íú
  24. '
  25. '▓┘╫≈┐╔─▄▒╗╟╢╠╫ (└²╚τú¼╥╗╕÷╬─╝■╕┤╓╞▓┘╫≈┐╔─▄╙╨╥╗╕÷╟╢╠╫╡─╖╜╧≥┤┤╜¿▓┘╫≈)íú
  26. '╚╬║╬╡╟┬╝╡─┤φ╬≤íó╛»╕µ╗≥╠ß╩╛╢╝╜½╨┤╡╜╚╒╓╛╬─╝■╡─┤²╫÷▓┘╫≈(╚τ╣√╙╨)╓╨íú
  27. '╔⌡╓┴╚τ╣√╡╟┬╝┴╦╥╗╕÷┤φ╬≤ú¼┤²╫÷▓┘╫≈╥▓▒╪╨δ▒╗╠ß╜╗╗≥╚í╧√íú
  28. '▓╬╝√╧┬├µ├┐╕÷║»╩²╡─╫ó╩═┐╔╥╘╡├╡╜╧Ω╧╕╨┼╧óíú
  29. '
  30.  
  31. '╙ª╙├│╠╨≥╔╛│²│╠╨≥╓╗╓º│╓ 32 ╬╗╣ñ│╠
  32.  
  33. '╚τ╣√─·▓╗╧ú═√╘┌╚╒╓╛╬─╝■╓╨│÷╧╓╛»╕µ╨┼╧óú¼╘≥╔Φ╓├╒Γ╕÷│ú╩²╬¬ FALSEíú
  34. Global Const fLOG_WARNINGS = True
  35.  
  36. '╚½╛╓▓┘╫≈╣╪╝ⁿ╫╓│ú╩²
  37. Global Const gstrKEY_PRIVATEFILE = "PrivateFile"
  38. Global Const gstrKEY_TEMPFILE = "TempFile"
  39. Global Const gstrKEY_SHAREDFILE = "SharedFile"
  40. Global Const gstrKEY_SYSTEMFILE = "SystemFile"
  41. Global Const gstrKEY_CREATEDIR = "CreateDir"
  42. Global Const gstrKEY_PROGMANGROUP = "ProgManGroup"
  43. Global Const gstrKEY_PROGMANITEM = "ProgManItem"
  44. Global Const gstrKEY_SHELLFOLDER = "ShellFolder"
  45. Global Const gstrKEY_SHELLLINK = "ShellLink"
  46. Global Const gstrKEY_DLLSELFREGISTER = "DllSelfRegister"
  47. Global Const gstrKEY_EXESELFREGISTER = "ExeSelfRegister"
  48. Public Const gstrKEY_TLBREGISTER = "TLBRegister"
  49. Global Const gstrKEY_REMOTEREGISTER = "RemoteRegister"
  50. Global Const gstrKEY_REGKEY = "RegKey"
  51. Global Const gstrKEY_REGVALUE = "RegValue"
  52.  
  53. 'VB5STKIT.DLL ╡╟┬╝┤φ╬≤
  54. Private Const LOGERR_SUCCESS = 0
  55. Private Const LOGERR_INVALIDARGS = 1
  56. Private Const LOGERR_OUTOFMEMORY = 2
  57. Private Const LOGERR_EXCEEDEDCAPACITY = 3
  58. Private Const LOGERR_WRITEERROR = 4
  59. Private Const LOGERR_NOCURRENTACTION = 5
  60. Private Const LOGERR_UNEXPECTED = 6
  61. Private Const LOGERR_FILENOTFOUND = 7
  62.  
  63. '╡╟┬╝┤φ╬≤╤╧╓╪╨╘
  64. Private Const LogErrOK = 1 ' ╘┌┤╦┤φ╬≤╗∙┤í╔╧┐╔╥╘╝╠╨°░▓╫░
  65. Private Const LogErrFatal = 2 ' ╘┌┤╦┤φ╬≤╗∙┤í╔╧▒╪╨δ╓╒╓╣░▓╫░
  66.  
  67. 'SKIT432.DLL ╜╙┐┌
  68. Private Declare Function DllAbortAction Lib "VB5STKIT.DLL" Alias "AbortAction" () As Long
  69. Private Declare Function DllAddActionNote Lib "VB5STKIT.DLL" Alias "AddActionNote" (ByVal lpszNote As String) As Long
  70. Private Declare Function DllChangeActionKey Lib "VB5STKIT.DLL" Alias "ChangeActionKey" (ByVal lpszNewKey As String) As Long
  71. Private Declare Function DllCommitAction Lib "VB5STKIT.DLL" Alias "CommitAction" () As Long
  72. Private Declare Function fDllWithinAction Lib "VB5STKIT.DLL" Alias "fWithinAction" () As Long
  73. Private Declare Function DllLogError Lib "VB5STKIT.DLL" Alias "LogError" (ByVal lpszERROR As String, ByVal lpszDURINGACTION As String, ByVal lpszErrMsg As String) As Long
  74. Private Declare Function DllLogNote Lib "VB5STKIT.DLL" Alias "LogNote" (ByVal lpszNote As String) As Long
  75. Private Declare Function DllLogWarning Lib "VB5STKIT.DLL" Alias "LogWarning" (ByVal lpszWARNING As String, ByVal lpszDURINGACTION As String, ByVal lpszWarningMsg As String) As Long
  76. Private Declare Function DllNewAction Lib "VB5STKIT.DLL" Alias "NewAction" (ByVal lpszKey As String, ByVal lpszData As String) As Long
  77. Private Declare Function DllEnableLogging Lib "VB5STKIT.DLL" Alias "EnableLogging" (ByVal lpszFilename As String) As Long
  78. Private Declare Function DllDisableLogging Lib "VB5STKIT.DLL" Alias "DisableLogging" () As Long
  79.  
  80. '-----------------------------------------------------------
  81. ' ╫╙│╠╨≥ú║AbortAction
  82. '
  83. ' ╓╨╓╣╡▒╟░▓┘╫≈
  84. '-----------------------------------------------------------
  85. '
  86. Sub AbortAction()
  87.     ShowLoggingError DllAbortAction(), LogErrFatal
  88. End Sub
  89.  
  90. '-----------------------------------------------------------
  91. ' ╫╙│╠╨≥ú║AddActionNote
  92. '
  93. ' ╘┌╚╒╓╛╬─╝■╓╨╡─╡▒╟░▓┘╫≈╧┬├µ╜⌠╜╙╫┼╠φ╝╙╥╗╕÷╠ß╩╛
  94. '-----------------------------------------------------------
  95. '
  96. Sub AddActionNote(ByVal strNote As String)
  97.     ShowLoggingError DllAddActionNote(strNote), LogErrOK
  98. End Sub
  99.  
  100. '-----------------------------------------------------------
  101. ' ╫╙│╠╨≥ú║ChangeActionKey
  102. '
  103. ' ╕─▒Σ╡▒╟░▓┘╫≈╡─╝ⁿ
  104. '-----------------------------------------------------------
  105. '
  106. Sub ChangeActionKey(ByVal strNewKey As String)
  107.     ShowLoggingError DllChangeActionKey(strNewKey), LogErrFatal
  108. End Sub
  109.  
  110. '-----------------------------------------------------------
  111. ' ╫╙│╠╨≥ú║CommitAction
  112. '
  113. ' ▒Ω╝╟╡▒╟░▓┘╫≈╥╤│╔╣ª═Ω│╔ú¼╕├▓┘╫≈╜½▒╗╩Σ│÷╡╜╚╒╓╛╬─╝■╓╨íú
  114. '-----------------------------------------------------------
  115. '
  116. Sub CommitAction()
  117.     ShowLoggingError DllCommitAction(), LogErrFatal
  118. End Sub
  119.  
  120. '-----------------------------------------------------------
  121. ' ╫╙│╠╨≥ú║DisableLogging
  122. '
  123. ' ╜√╓╣╙ª╙├│╠╨≥╔╛│²╡╟┬╝íú
  124. ' ╦∙╙╨╡─╡╟┬╝║»╩²╚╘┐╔╡≈╙├ú¼▓ó╟╥▒╪╨δ╥└╛╔┐╔╥╘╨▐╕─ú¼╡½▓╗╘╩╨φ╧≥┤┼┼╠╨┤╩²╛▌íú
  125. '-----------------------------------------------------------
  126. '
  127. Sub DisableLogging()
  128.     ShowLoggingError DllDisableLogging(), LogErrFatal
  129. End Sub
  130.  
  131. '-----------------------------------------------------------
  132. ' ╫╙│╠╨≥ú║EnableLogging
  133. '
  134. ' ╜√╓╣╙ª╙├│╠╨≥░▓╫░/╔╛│²╓╕╢¿╚╒╓╛╬─╝■╡─╡╟┬╝íú
  135. '-----------------------------------------------------------
  136. '
  137. Sub EnableLogging(ByVal strLogFileName As String)
  138.     ShowLoggingError DllEnableLogging(strLogFileName), LogErrFatal
  139. End Sub
  140.  
  141. '-----------------------------------------------------------
  142. ' ╫╙│╠╨≥ú║LogError
  143. '
  144. ' ╡╟┬╝╥╗╕÷┤φ╬≤╡╜╚╒╓╛╬─╝■ú¼▓┘╫≈▓ó╬┤╓╨╓╣íú
  145. '-----------------------------------------------------------
  146. '
  147. Sub LogError(ByVal strErr As String)
  148.     ShowLoggingError DllLogError(ResolveResString(resLOG_ERROR), ResolveResString(resLOG_DURINGACTION), strErr), LogErrFatal
  149. End Sub
  150.  
  151. '-----------------------------------------------------------
  152. ' ╫╙│╠╨≥ú║LogWarning
  153. '
  154. ' ╡╟┬╝╥╗╕÷╛»╕µ╡╜╚╒╓╛╬─╝■ú¼▓┘╫≈▓ó╬┤╓╨╓╣íú
  155. ' ╛»╕µ╙δ┤φ╬≤╡─▓╗═¼╘┌╙┌═¿│ú╛»╕µ║▄─╤╥²╞≡╫ε╓╒╙├╗º╡─╫ó╥Γíú.
  156. ' ═¼╤∙╡╪ú¼╥²╡╝│╠╨≥╥▓┤╙▓╗╡╟┬╝╛»╕µú¼╦ⁿ╓╗╡╟┬╝┤φ╬≤íú
  157. '
  158. ' ╣╪╙┌╛»╕µ╡─╡╟┬╝┐╔╥╘═¿╣²╕─▒Σ▒╛─ú┐Θ╡─╔∙├≈╥╗╜┌╓╨╡─ fLOG_WARNINGS ╓╡╢°╣╪▒╒íú
  159. '-----------------------------------------------------------
  160. '
  161. Sub LogWarning(ByVal strWarning As String)
  162.     If fLOG_WARNINGS Then
  163.         ShowLoggingError DllLogWarning(ResolveResString(resLOG_WARNING), ResolveResString(resLOG_DURINGACTION), strWarning), LogErrFatal
  164.     End If
  165. End Sub
  166.  
  167. '-----------------------------------------------------------
  168. ' ╫╙│╠╨≥ú║LogNote
  169. '
  170. ' ╡╟┬╝╥╗╕÷╠ß╩╛╡╜╚╒╓╛╬─╝■íú╬¬╓┤╨╨╒Γ╕÷╫╙│╠╨≥╢°╙╨╡─╥╗╕÷╡▒╟░▓┘╫≈▓╗╩╟▒╪╨δ╡─íú
  171. '-----------------------------------------------------------
  172. '
  173. Sub LogNote(ByVal strNote As String)
  174.     ShowLoggingError DllLogNote(strNote), LogErrOK
  175. End Sub
  176.  
  177. '-----------------------------------------------------------
  178. ' ╫╙│╠╨≥ú║NewAction
  179. '
  180. ' ▒Ω╝╟╡╟┬╝╙├╡─╨┬▓┘╫≈╡─┐¬╩╝íú╚τ╣√╒Γ╕÷╫╙│╠╨≥╘┌╚╬║╬╡▒╟░▓┘╫≈▒╗╠ß╜╗╗≥╓╨╓╣╓«╟░▒╗╡≈╙├ú¼
  181. ' ─╟├┤╟░├µ╡─▓┘╫≈╜½╘┌╒╗╓╨▒╗╠µ╗╗íú
  182. ' ╥╗╡⌐╨┬╡─▓┘╫≈╥╤▒╗╠ß╜╗╗≥╓╨╓╣ú¼╟░├µ╡─▓┘╫≈╜½╘┘┤╬▒╗╝ñ╗εíú
  183. ' ╘┌▓┘╫≈╠ß╜╗╗≥╓╨╓╣╓«║≤ú¼╜½┤≥╙í│÷╣╪╙┌┤φ╬≤íó╛»╕µíó╠ß╩╛║═▓┘╫≈╜ß╣√╡─▒¿╕µíú
  184. ' ╢α╕÷▓┘╫≈╜½░┤╧╚╜°╧╚│÷╡─╖╜╩╜╙╔╒Γ╕÷╫╙│╠╨≥╓╪╕┤╡≈╙├íú
  185. '-----------------------------------------------------------
  186. '
  187. Sub NewAction(ByVal strKey As String, ByVal strData As String)
  188.     ShowLoggingError DllNewAction(strKey, strData), LogErrFatal
  189. End Sub
  190.  
  191. Sub ShowLoggingError(ByVal lErr As Long, ByVal lErrSeverity As Long)
  192.     If lErr = LOGERR_SUCCESS Then
  193.         Exit Sub
  194.     End If
  195.     
  196.     Dim strErrMsg As String
  197.     Static fRecursive As Boolean
  198.     
  199.     If fRecursive Then
  200.         '╚τ╣√╬╥├╟╒²╘┌╡▌╣Θ╡≈╙├ú¼╛═╙╨┐╔─▄╘┌╩Σ│÷┤φ╬≤╡╜╚╒╓╛╬─╝■╩▒╡├╡╜┤φ╬≤íú
  201.         '│²┴╦╣╪▒╒╡╟┬╝▓ó╓╨╓╣░▓╫░═Γú¼╩▓├┤╥▓▓╗╥¬╫÷íú
  202.         DisableLogging
  203.         MsgError ResolveResString(resUNEXPECTED), vbExclamation Or vbOKOnly, gstrTitle
  204.         ExitSetup frmSetup1, gintRET_FATAL
  205.     End If
  206.  
  207.     fRecursive = True
  208.  
  209.     Select Case lErr
  210.         Case LOGERR_OUTOFMEMORY, LOGERR_WRITEERROR, LOGERR_UNEXPECTED, LOGERR_FILENOTFOUND
  211.             strErrMsg = ResolveResString(resUNEXPECTED)
  212.         
  213.         Case LOGERR_INVALIDARGS, LOGERR_EXCEEDEDCAPACITY, LOGERR_NOCURRENTACTION
  214.             '╫ó╥Γú║╒Γ╨⌐┤φ╬≤╕ⁿ╧≤╩╟╒Γ╕÷╣ñ│╠╡─▓╗╒²╚╖╢¿╓╞╢°╡╝╓┬╡─╜ß╣√íú
  215.             '╥¬╚╖▒ú─·╢╘╒Γ╕÷╬─╝■╦∙╫÷╡─╚╬║╬╕─▒Σ╢╝╩╟║╧╖¿▓ó╟╥╬▐╬≤╡─íú
  216.             'LOGERR_INVALIDARGS -- ╡╟┬╝║»╩²╡─╥╗╕÷▓╬╩²╖╟╖¿╗≥▓╗╒²╚╖
  217.             'LOGERR_EXCEEDEDCAPACITY -- ┤µ╖┼▓┘╫≈╡─╒╗╡─╚▌┴┐┐╔─▄╥╤╛¡│¼│÷íú
  218.             '   ┤≤╢α╩²╟Θ┐÷╧┬ú¼╒Γ╥Γ╬╢╫┼ CommitAction ╗≥ AbortAction ╙∩╛Σ╘┌┤·┬δ╓╨╢¬╩ºíú
  219.             'LOGERR_NOCURRENTACTION -- ╥¬╩╣╙├╡─╡╟┬╝║»╩²╥¬╟≤╙╨╥╗╕÷╡▒╟░▓┘╫≈ú¼╡½╒Γ└∩├╗╙╨íú
  220.             '   ╝∞▓Θ╩╟╖±╢¬╩º┴╦╥╗╠⌡ NewAction ╙∩╛Σíú
  221.             strErrMsg = ResolveResString(resUNEXPECTED)
  222.         Case Else
  223.             strErrMsg = ResolveResString(resUNEXPECTED)
  224.         '╜ß╩° Case
  225.     End Select
  226.     
  227.     Dim iRet As Integer
  228.     Dim fAbort As Boolean
  229.     
  230.     fAbort = False
  231.     If lErrSeverity = LogErrOK Then
  232.         ' ╙├╗º─▄╣╗╤í╘±╩╟╖±╝╠╨°
  233.         iRet = MsgFunc(strErrMsg, MB_OKCANCEL Or MB_ICONEXCLAMATION, gstrTitle)
  234.         If gfNoUserInput Then iRet = IDCANCEL ' ╚τ╣√╩╟í░░▓╛▓í▒─ú╩╜░▓╫░ú¼╘≥▓╗─▄╝╠╨°íú
  235.         Select Case iRet
  236.             Case IDOK
  237.             Case IDCANCEL
  238.                 fAbort = True
  239.             Case Else
  240.                 fAbort = True
  241.             '╜ß╩° Case
  242.         End Select
  243.     Else
  244.         ' ╓┬├ⁿ┤φ╬≤
  245.         MsgFunc strErrMsg, MB_OK Or MB_ICONEXCLAMATION, gstrTitle
  246.         fAbort = True
  247.     End If
  248.  
  249.     If fAbort Then
  250.         ExitSetup frmCopy, gintRET_ABORT
  251.     End If
  252.  
  253.     fRecursive = False
  254.  
  255. End Sub
  256.  
  257. '-----------------------------------------------------------
  258. ' ║»╩²ú║fWithinAction
  259. '
  260. ' ╚τ╣√╙╨╡▒╟░ Actionú¼╖╡╗╪ TRUE
  261. '-----------------------------------------------------------
  262. '
  263. Function fWithinAction() As Boolean
  264.     fWithinAction = fDllWithinAction()
  265. End Function
  266.  
  267.