Results 1 to 2 of 2

Thread: Shell / CreateProcessA fails after using a class

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    4

    Question Shell / CreateProcessA fails after using a class

    I hope I can explain this..

    I am trying the use the CreateProcessA function to shell to DOS to run a DOS application.

    If I call the ExecCmd function from the Main form when I start the application, the process works fine. It shells to DOS and runs the DOS application. No problem.

    If I call then ExecCmd from within a class with the same command line that was used form the main Form, it does not work. Also, if I call the same ExecCmd function AFTER I use the class, the same ExecCmd function called from Main form no longer works. The CreateProcessA function within the ExecCmd returns a "1" instead of "255" afte the class is referenced.

    Does the class cause an issue with CreateProcessA function? Is there a focus problem when using a class??



    ExecCmd is in a Module
    VB Code:
    1. Public Sub ExecCmd(sCmdline As String)
    2.     Dim proc As PROCESS_INFORMATION
    3.     Dim start As STARTUPINFO
    4.     Dim sa As SECURITY_ATTRIBUTES
    5.     Dim ReturnValue As Long
    6.  
    7.     start.cb = Len(start)      
    8.     sa.nLength = Len(sa)
    9.     sa.bInheritHandle = -1
    10.  
    11.     ReturnValue = CreateProcessA(0&, sCmdline, sa, sa, True, NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
    12.    
    13.     Do
    14.        ReturnValue = WaitForSingleObject(proc.hProcess, 0)
    15.        DoEvents
    16.     Loop Until ReturnValue <> 258
    17.  
    18.     ReturnValue = CloseHandle(proc.hProcess)
    19.  
    20. End Sub

  2. #2

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    4

    Re: Shell / CreateProcessA fails after using a class

    Never mind.... It would help if the file handle was not left open.


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