When I try to compile my code, I get the following error:
VB Code:
  1. Compile error:
  2.  
  3. Cannot define a Public user-defined type within a private object module

on this line:
VB Code:
  1. Type PROCESSENTRY32


Can anyone tell me how to fix this?


source:
VB Code:
  1. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  2. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  3. Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  4.  
  5. Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
  6. Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
  7. Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
  8. Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, lProcessID As Long) As Long
  9. Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  10. Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
  11.  
  12.  
  13. Private winHwnd1 As Long
  14. Private winHwnd2 As Long
  15. Const SW_SHOWNORMAL = 1
  16. Const WM_CLOSE = &H10
  17.  
  18. Type PROCESSENTRY32
  19.     dwSize As Long
  20.     cntUsage As Long
  21.     th32ProcessID As Long
  22.     th32DefaultHeapID As Long
  23.     th32ModuleID As Long
  24.     cntThreads As Long
  25.     th32ParentProcessID As Long
  26.     pcPriClassBase As Long
  27.     dwFlags As Long
  28.     szexeFile As String * 6400
  29. End Type
  30.  
  31.  
  32. Public Function StopApp(myName As String) As Boolean
  33.     Const PROCESS_ALL_ACCESS = 0
  34.     Dim uProcess As PROCESSENTRY32
  35.     Dim rProcessFound As Long
  36.     Dim hSnapshot As Long
  37.     Dim szExename As String
  38.     Dim exitCode As Long
  39.     Dim myProcess As Long
  40.     Dim AppKill As Boolean
  41.     Dim appCount As Integer
  42.     Dim i As Integer
  43.     On Local Error GoTo Finish
  44.     appCount = 0
  45.    
  46.     Const TH32CS_SNAPPROCESS As Long = 2&
  47.    
  48.     uProcess.dwSize = Len(uProcess)
  49.     hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
  50.     rProcessFound = ProcessFirst(hSnapshot, uProcess)
  51.    
  52.     Do While rProcessFound
  53.         i = InStr(1, uProcess.szexeFile, Chr(0))
  54.         szExename = LCase$(Left$(uProcess.szexeFile, i - 1))
  55.         If Right$(szExename, Len(myName)) = LCase$(myName) Then
  56.             StopApp = True
  57.             appCount = appCount + 1
  58.             myProcess = OpenProcess(PROCESS_ALL_ACCESS, False, uProcess.th32ProcessID)
  59.             AppKill = TerminateProcess(myProcess, exitCode)
  60.             Call CloseHandle(myProcess)
  61.         End If
  62.         rProcessFound = ProcessNext(hSnapshot, uProcess)
  63.     Loop
  64.  
  65.     Call CloseHandle(hSnapshot)
  66. Finish:
  67. End Function
  68.  
  69.  
  70.  
  71.  
  72.  
  73. Private Sub CloseIt_Click()
  74.     StopApp (App.Path & "\portablewebap\portablewebap.exe")
  75.     StopApp (App.Path & "\portablefirefox\PortableFirefox.exe")
  76.     Unload Me
  77. End Sub
  78.  
  79. Private Sub OpenIt_Click()
  80.     winHwnd1 = ShellExecute(Me.hwnd, "open", App.Path & "\portablewebap\portablewebap.exe", vbNullString, App.Path & "\portablewebap\", SW_SHOWNORMAL)
  81.     winHwnd2 = ShellExecute(Me.hwnd, "open", App.Path & "\portablefirefox\PortableFirefox.exe", "-URL ""http://localhost:800"" -fullscreen", "C:\", SW_SHOWNORMAL)
  82. End Sub
  83.  
  84. Private Sub RestartIt_Click()
  85.     winHwnd2 = ShellExecute(Me.hwnd, vbNullString, "portablefirefox\PortableFirefox.exe", "-URL ""http://localhost:800"" -fullscreen", "C:\", SW_SHOWNORMAL)
  86. End Sub