Bosna i Hercegovina



#1 07.09.2015-13:17
Avko Offline
Administrator
Registrovan/a od: 28.05.2014-09:21
Komentari: 3,319


Subject: shell i kill funkcija u VB6
DownloadIzvorni kod (Visual Basic):
  1. option explicit
  2. Dim zipProgram as string
  3.  
  4. zipProgram=App.Path & "\7za e imeFajla.zip -y"
  5.  
  6. Shell zipProgram
  7. Kill imeFajla.zip

U imeFajla.zip imam komprimiranu datoteku imeFajla.bin
program radi ako na liniju koda gdje se nalazi Kill naredba stavim breakpoint pa sa F8 napravim korak, no ako ne stavim zaustavnu tocku onda mi se ne extrakta iz imeFajla.zip datoteka imeFajla.bin.
Zna li itko na ovom svijetu, kako nakon extrakta zip datoteke obrisati zip datoteku.
Nekako mi izgleda kao da shell ne stigne extraktati a kill naredba vec obrise zip datoteku i zbog toga nemam imeFajla.bin
Život je moja domovina.
↑  ↓

#2 08.09.2015-07:35
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 9,834


Subject: Re: shell i kill funkcija u VB6
Ima negdje procedura cini mi se da se zove uspori shell.
Upravo se to desava sto si sam zakljucio tj. kil sustigne naredbu sell koja jos nije ni zavrsila.
Pozdrav
↑  ↓

#3 08.09.2015-08:19
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 9,834


Subject: Re: shell i kill funkcija u VB6
Evo probaj sa ovom procedurom.
DownloadIzvorni kod (Visual Basic):
  1. Private Sub UsporiShell(ByVal program_name As String, ByVal window_style As Integer)
  2. Dim process_id As Long
  3. Dim process_handle As Long
  4.     ' Start the program.
  5.    On Error GoTo ShellError
  6.     process_id = Shell(program_name, window_style)
  7.     On Error GoTo 0
  8.  
  9.     ' Wait for the program to finish.
  10.    ' Get the process handle.
  11.    process_handle = OpenProcess(SYNCHRONIZE, 0, process_id)
  12.     If process_handle <> 0 Then
  13.         WaitForSingleObject process_handle, INFINITE
  14.         CloseHandle process_handle
  15.     End If
  16.  
  17.     Exit Sub
  18.  
  19. ShellError:
  20.     MsgBox "Error starting task " & _
  21.          program_name & vbCrLf & _
  22.         Err.Description, vbOKOnly Or vbExclamation, _
  23.         "Error"
  24. End Sub
program_name-App.Path & "\7za e imeFajla.zip -y"
window_style=0
Pozdrav
↑  ↓

#4 08.09.2015-09:02
Avko Offline
Administrator
Registrovan/a od: 28.05.2014-09:21
Komentari: 3,319


Subject: 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

DownloadIzvorni kod (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:
Informacije o fajlu: rar  VB6_shell_Kill.rar
Preuzimanja: 81
Veličina: 352.84 KB


Život je moja domovina.
Ovaj komentar je mijenjan 1 puta. zadnja izmjena 08.09.2015-09:18 od strane Avko. ↑  ↓

#5 08.09.2015-12:06
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 9,834


Subject: Re: shell i kill funkcija u VB6
U pravu si ovo je api i ja zaboravio dodati api na vrh modula.
DownloadIzvorni kod (Visual Basic):
  1. Option Compare Database
  2. Option Explicit
  3. Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
  4. Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
  5. Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  6.  
  7. Private Const SYNCHRONIZE = &H100000
  8. Private Const INFINITE = -1&
  9.  
  10. ' Usporava shel
  11. ' to finish, hiding while we wait.
  12. Private Sub UsporiShell(ByVal program_name As String, ByVal window_style As Integer)
  13. Dim process_id As Long
  14. Dim process_handle As Long
  15.     ' Start the program.
  16.    On Error GoTo ShellError
  17.     process_id = Shell(program_name, window_style)
  18.     On Error GoTo 0
  19.  
  20.     ' Wait for the program to finish.
  21.    ' Get the process handle.
  22.    process_handle = OpenProcess(SYNCHRONIZE, 0, process_id)
  23.     If process_handle <> 0 Then
  24.         WaitForSingleObject process_handle, INFINITE
  25.         CloseHandle process_handle
  26.     End If
  27.  
  28.     Exit Sub
  29.  
  30. ShellError:
  31.     MsgBox "Error starting task " & _
  32.          program_name & vbCrLf & _
  33.         Err.Description, vbOKOnly Or vbExclamation, _
  34.         "Error"
  35. End Sub
program_name-App.Path & "\7za e imeFajla.zip -y"
window_style=0

Window stil moze biti:
vbHide     0     Window is hidden and focus is passed to the hidden window.
vbNormalFocus     1     Window has focus and is restored to its original size and position.
vbMinimizedFocus 2     Window is displayed as an icon with focus.
vbMaximizedFocus    3    Window is maximized with focus.
vbNormalNoFocus    4    Window is restored to its most recent size and position. The currently active window remains active.
vbMinimizedNoFocus    6    Window is displayed as an icon. The currently active window remains active.
Pozdrav
↑  ↓

#6 08.09.2015-12:23
Avko Offline
Administrator
Registrovan/a od: 28.05.2014-09:21
Komentari: 3,319


Subject: Re: shell i kill funkcija u VB6
evo probao i radi, hvala.
koristicu tvoju proceduru, em je manja em odiše kreativnošću.
osjeća se umjetnost ljubavlju sazdana u njeno tijelo.
Život je moja domovina.
↑  ↓

Stranice (1): 1


All times are GMT +01:00. Current time: 16.12.2018-18:18.