Results 1 to 4 of 4

Thread: run a exe from a dll and pass a string to the exe?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    292

    run a exe from a dll and pass a string to the exe?

    Hi everyone!


    How can i run a exe from a dll and pass a variable to the exe?


    Thanks.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: run a exe from a dll and pass a string to the exe?

    In your dll you can have something like this:
    Code:
    Public Sub RunExe(prog As String, arglist As String)
    
        Shell prog & " " & arglist, vbNormalFocus
    
    End Sub
    where
    - PROG must have full exe path+name
    - and arglist is some list of command line arguments

    In the program that will run on main ,form_load OR sub main you'll have to parse command line args like this:
    Code:
    Private Sub Form_Load()
    Dim myComArgs As String
    
        myComArgs = Command()
        
        'you take from here...
    
    End Sub

  3. #3
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: run a exe from a dll and pass a string to the exe?

    Good answer, but I'd tend to generalize it to:
    Code:
    Public Sub RunExe(prog As String, arglist As String)
    
        Shell """" & prog & """ " & arglist, vbNormalFocus
    
    End Sub
    Paths often have spaces, etc. in them.

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: run a exe from a dll and pass a string to the exe?

    Quote Originally Posted by dilettante
    Good answer, but I'd tend to generalize it...
    Thanks but then you have to add Error Handler, "turn" sub into a function ... and so on ...
    But I agree, dbl quotes most likely needed.

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