Avko |
07.09.2015 14:17 |
Predmet:shell i kill funkcija u VB6
PreuzmiIzvorni kôd (Visual Basic):option explicit
Dim zipProgram as string
zipProgram=App.Path & "\7za e imeFajla.zip -y"
Shell zipProgram
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 |
zxz |
08.09.2015 08:35 |
Predmet: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. |
zxz |
08.09.2015 09:19 |
Predmet:Re: shell i kill funkcija u VB6
Evo probaj sa ovom procedurom.
PreuzmiIzvorni kôd (Visual Basic):Private Sub UsporiShell(ByVal program_name As String, ByVal window_style As Integer)
Dim process_id As Long
Dim process_handle As Long
' Start the program.
On Error GoTo ShellError
process_id = Shell(program_name, window_style)
On Error GoTo 0
' Wait for the program to finish.
' Get the process handle.
process_handle = OpenProcess(SYNCHRONIZE, 0, process_id)
If process_handle <> 0 Then
WaitForSingleObject process_handle, INFINITE
CloseHandle process_handle
End If
Exit Sub
ShellError:
MsgBox "Error starting task " & _
program_name & vbCrLf & _
Err.Description, vbOKOnly Or vbExclamation, _
"Error"
End Sub
program_name-App.Path & "\7za e imeFajla.zip -y"
window_style=0 |
Avko |
08.09.2015 10:02 |
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):Option Explicit
DefInt A-Z
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Byte
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
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
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Dim Path As String
Private Sub ExecCmd(CmdLine As String)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
Dim ret&
'
' Initialize the STARTUPINFO structure:
'
start.cb = Len(start)
'
' Start the shelled application:
'
ret& = CreateProcessA(0&, CmdLine, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
'
' Wait for the shelled application to finish:
'
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
ret& = CloseHandle(proc.hProcess)
MsgBox "process has finished"
End Sub
Private Sub cmdStart_Click()
Me.Hide
Dim program_name As String
program_name = App.Path & "\7za e data.zip -y"
ExecCmd program_name
Kill App.Path & "\Data.zip"
Me.Show
End Sub
Private Sub Form_Load()
Path = App.Path
If Right$(Path, 1) <> "\" Then Path = Path & "\"
Me.Show
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 (Velicina datoteke:352.84 KB)
|
zxz |
08.09.2015 13:06 |
Predmet:Re: shell i kill funkcija u VB6
U pravu si ovo je api i ja zaboravio dodati api na vrh modula.
PreuzmiIzvorni kôd (Visual Basic):Option Compare Database
Option Explicit
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const SYNCHRONIZE = &H100000
Private Const INFINITE = -1&
' Usporava shel
' to finish, hiding while we wait.
Private Sub UsporiShell(ByVal program_name As String, ByVal window_style As Integer)
Dim process_id As Long
Dim process_handle As Long
' Start the program.
On Error GoTo ShellError
process_id = Shell(program_name, window_style)
On Error GoTo 0
' Wait for the program to finish.
' Get the process handle.
process_handle = OpenProcess(SYNCHRONIZE, 0, process_id)
If process_handle <> 0 Then
WaitForSingleObject process_handle, INFINITE
CloseHandle process_handle
End If
Exit Sub
ShellError:
MsgBox "Error starting task " & _
program_name & vbCrLf & _
Err.Description, vbOKOnly Or vbExclamation, _
"Error"
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. |
Avko |
08.09.2015 13:23 |
Predmet: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. |