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 / ReadOutput.ctl < prev   
Text File  |  2005-10-16  |  5KB  |  115 lines

  1. VERSION 5.00
  2. Begin VB.UserControl ReadOutput 
  3.    BackColor       =   &H80000007&
  4.    ClientHeight    =   765
  5.    ClientLeft      =   0
  6.    ClientTop       =   0
  7.    ClientWidth     =   975
  8.    InvisibleAtRuntime=   -1  'True
  9.    ScaleHeight     =   765
  10.    ScaleWidth      =   975
  11.    Begin VB.Image imgIcon 
  12.       Height          =   735
  13.       Left            =   0
  14.       Picture         =   "ReadOutput.ctx":0000
  15.       Stretch         =   -1  'True
  16.       Top             =   0
  17.       Width           =   975
  18.    End
  19. End
  20. Attribute VB_Name = "ReadOutput"
  21. Attribute VB_GlobalNameSpace = False
  22. Attribute VB_Creatable = True
  23. Attribute VB_PredeclaredId = False
  24. Attribute VB_Exposed = False
  25. 'VERSION 2.0 OF READ OUTPUT [CONTROL]
  26.  
  27. 'You may use this code in your project as long as you dont claim its yours ;)
  28.  
  29. 'This program reads the output of CLI (Command Line Interface) Applications.
  30. 'Examples of CLI Applications are:
  31. '   -PING.EXE
  32. '   -NETSTAT
  33. '   -TRACERT
  34. 'This program will grab the output and call events so that you can process the commands.
  35. 'NOTE:  I got about 50% of this code from some site about 2 years ago, just found it and fixed some bugs
  36. '       and transformed it into a user-friendly control.
  37. '
  38. 'Please vote if you like, complaint about bugs if you find any, but I also appreciate comments ;)
  39. 'Thanks again
  40. '-Endra
  41.  
  42.  
  43. 'ADDONS:
  44. '   -The Terminate Process ID was originaly coded by Nick Campbeln. Thanks a bunch ;)
  45.         '-His code is surrounded by POUND (##) signs.
  46.  
  47. Option Explicit 'force declarations of variables
  48.  
  49.  
  50. '#####################################################################################
  51. '#####################################################################################
  52. '#####################################################################################
  53.     '#### Functions/Consts used for CloseProcess()
  54. 'Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  55. Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  56. Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
  57. Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
  58. Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
  59.  
  60. Private Const WM_CLOSE As Long = &H10
  61. Private Const WM_DESTROY As Long = &H2
  62. 'Private Const WM_QUERYENDSESSION = &H11
  63. Private Const WM_ENDSESSION = &H16
  64. Private Const PROCESS_TERMINATE As Long = &H1
  65.  
  66.     '#### Functions/Consts/Types used for GetVersionEx() API
  67. Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
  68. Private Type OSVERSIONINFO
  69.     OSVSize As Long
  70.     dwVerMajor As Long
  71.     dwVerMinor As Long
  72.     dwBuildNumber As Long           '#### NT: Build Number, 9x: High-Order has Major/Minor ver, Low-Order has build
  73.     PlatformID As Long
  74.     szCSDVersion As String * 128    '#### NT: ie- "Service Pack 3", 9x: 'arbitrary additional information'
  75. End Type
  76. 'Private Const VER_PLATFORM_WIN32s = 0
  77. Private Const VER_PLATFORM_WIN32_WINDOWS = 1
  78. Private Const VER_PLATFORM_WIN32_NT = 2
  79.  
  80.     '#### Functions/Consts used for CloseAll()
  81. Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
  82. Private Declare Function GetDesktopWindow Lib "user32" () As Long
  83. Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
  84. Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
  85. Private Const GW_HWNDNEXT = 2
  86. Private Const GW_CHILD = 5
  87.  
  88.     '#### Required local vars
  89. Private g_bIsInit As Boolean
  90. Private g_bIs9x As Boolean
  91. '#####################################################################################
  92. '#####################################################################################
  93. '#####################################################################################
  94.  
  95.  
  96. 'private variables
  97. Dim sCommand As String
  98. Dim bProcessing As Boolean
  99. Dim bCancelProcess As Boolean
  100.  
  101. 'Public Events
  102. Public Event Error(ByVal Error As String, LastDLLError As Long) 'Errors go here
  103. Public Event GotChunk(ByVal sChunk As String, ByVal LastChunk As Boolean)                   'Chunk Output detected, launch this event
  104. Public Event Complete()                                         'Raise event when its done reading output
  105. Public Event Starting()                                         'Raised when you can start the reading
  106. Public Event Canceled()                                         'Raised when you canceled.
  107. 'The following are all API Calls and Types.
  108. 'You could probably find more information on them if you google them so I wont comment them at all.
  109. Private Declare Function CreatePipe Lib "kernel32" ( _
  110.     phReadPipe As Long, _
  111.     phWritePipe As Long, _
  112.     lpPipeAttributes As Any, _
  113.     ByVal nSize As Long) As Long
  114. es.
  115. '    eadinF