Results 1 to 3 of 3

Thread: Shell applications

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    13

    Question

    I need to know when my shelled application has finished (creating a .zip file) and tried using the code posted on VB-World, but keep getting this error:

    User-defined types and fixed-length strings not allowed as the type of a Public member of an object module; Private object modules not allowed as the type of a public member of a public object modules

    for this code:

    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

    Anybody know why I am getting this error? The code is located in the (general) (declarations) section of my form. Also, is this really the simplest way to know when the app has finished?

    Thanks,

    Shawn

  2. #2
    Lively Member
    Join Date
    Jan 1999
    Location
    India
    Posts
    85
    This is how I am creating ZIp Files


    Public Function ZipFile(ByVal SourceFilepath As String, ByVal DestFileName As String) As Long
    On Error GoTo ErrRoutine
    ' Shells a new process and waits for it to complete.
    ' Calling application is responsive while new process
    ' executes. It will react to new events, though execution
    ' of the current thread will not continue.
    '
    Dim ProcessID As Long
    Dim hProcess As Long
    Dim nRet As Long
    Const fdwAccess = PROCESS_QUERY_INFORMATION
    Dim TempFile As String: TempFile = g_ReportDirectroy & "\temp.zip"
    Dim FileObj As New FileSystemObject
    If Not FileObj.FolderExists(g_ReportDirectroy) Then
    FileObj.CreateFolder g_ReportDirectroy
    Else
    If FileObj.FileExists(TempFile) Then
    FileObj.DeleteFile TempFile, True
    End If
    End If
    On Error Resume Next
    ProcessID = Shell(GetShortPath(App.Path & "\utilities\pkzip") & " " & GetShortPath(TempFile) & " " & GetShortPath(SourceFilepath & DestFileName & ".pdf"), vbHide)
    If Err Then
    Err.Raise vbObjectError + Err.Number, "ZipFile", "Unable to execute Zip Utility"
    Exit Function
    End If
    On Error GoTo 0
    hProcess = OpenProcess(fdwAccess, False, ProcessID)
    Do
    GetExitCodeProcess hProcess, nRet
    DoEvents
    Sleep 200
    Loop While nRet = STILL_ACTIVE
    Call CloseHandle(hProcess)
    FileObj.CopyFile TempFile, g_ReportDirectroy & "\" & DestFileName & ".zip"
    FileObj.DeleteFile TempFile
    ZipFile = nRet
    Exit Function
    End Function


    The API's and Constants I used was

    Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
    Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

    Private Const PROCESS_QUERY_INFORMATION = &H400
    Private Const STILL_ACTIVE = &H103
    Const MAX_COMPUTERNAME_LENGTH As Long = 15&


    I have used some global variable But you can replace it with some values.

    Please check this works for you

    Ramdas





  3. #3
    New Member
    Join Date
    May 2000
    Location
    sweden
    Posts
    5
    Grizzly, you get that errormessage because you cant declare public functions in a form, try pasting it in a module instead or put "private" in front of your function declaration.
    /matse

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width