Prikazi cijelu temu 08.09.2015 10:02
Avko Van mreze
Administrator
Registrovan od:28.05.2014
Lokacija:zagreb


Predmet:Re: shell i kill funkcija u VB6
compile error:
Variable not defined

zaplavi mi se ovdje : process_handle = OpenProcess(SYNCHRONIZE, 0, process_id)
ovo:SYNCHRONIZE

evo nasao na internetu i radi

PreuzmiIzvorni kôd (Visual Basic):
  1. Option Explicit
  2. DefInt A-Z
  3.  
  4. Private Type STARTUPINFO
  5.   cb As Long
  6.   lpReserved As String
  7.   lpDesktop As String
  8.   lpTitle As String
  9.   dwX As Long
  10.   dwY As Long
  11.   dwXSize As Long
  12.   dwYSize As Long
  13.   dwXCountChars As Long
  14.   dwYCountChars As Long
  15.   dwFillAttribute As Long
  16.   dwFlags As Long
  17.   wShowWindow As Integer
  18.   cbReserved2 As Integer
  19.   lpReserved2 As Byte
  20.   hStdInput As Long
  21.   hStdOutput As Long
  22.   hStdError As Long
  23. End Type
  24.  
  25. Private Type PROCESS_INFORMATION
  26.   hProcess As Long
  27.   hThread As Long
  28.   dwProcessID As Long
  29.   dwThreadID As Long
  30. End Type
  31.  
  32. Private Const NORMAL_PRIORITY_CLASS = &H20&
  33. Private Const INFINITE = -1&
  34.  
  35. Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
  36. Private Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
  37. Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  38.  
  39. Dim Path As String
  40. Private Sub ExecCmd(CmdLine As String)
  41.  Dim proc As PROCESS_INFORMATION
  42.  Dim start As STARTUPINFO
  43.  Dim ret&
  44.  
  45.  '
  46. ' Initialize the STARTUPINFO structure:
  47. '
  48. start.cb = Len(start)
  49.  
  50.  '
  51. ' Start the shelled application:
  52. '
  53. ret& = CreateProcessA(0&, CmdLine, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
  54.  
  55.  '
  56. ' Wait for the shelled application to finish:
  57. '
  58. ret& = WaitForSingleObject(proc.hProcess, INFINITE)
  59.  ret& = CloseHandle(proc.hProcess)
  60.  
  61.  MsgBox "process has finished"
  62. End Sub
  63. Private Sub cmdStart_Click()
  64.  
  65.     Me.Hide
  66.     Dim program_name As String
  67.     program_name = App.Path & "\7za e data.zip -y"
  68.     ExecCmd program_name
  69.     Kill App.Path & "\Data.zip"
  70.     Me.Show
  71. End Sub
  72. Private Sub Form_Load()
  73.  Path = App.Path
  74.  
  75.  If Right$(Path, 1) <> "\" Then Path = Path & "\"
  76.  
  77.  Me.Show
  78. End Sub

jos me zanima dali ovo u proceduri Form_Load
If Right$(Path, 1) <> "\" Then Path = Path & "\"
stavlja znak \ pa necu morati dodavati nigdje u programu App.Path & "/"
i jos me zanima kako iskljuciti dos prozor da se nevidi

Prilozi:
VB6_shell_Kill.rar
Preuzimanja:347
Velicina datoteke:352.84 KB


zivot je moja domovina.
Ovaj post je ureden 1 puta. Posljednja izmjena 08.09.2015 10:18 od strane Avko.