Results 1 to 10 of 10

Thread: Pass a global variable from a dll to a exe??

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    292

    Pass a global variable from a dll to a exe??

    HI everyone!

    How can i pass a global variable from dll project to a exe file, after this i want to run the exe also from the dll.

    How can i do this?

    thanks.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: Pass a global variable from a dll to a exe??

    You're going to have to explain that a bit better. If a variable is truly global, then you don't need to pass it anywhere. Therefore, I would assume that you mean that the variable is global to the dll, which I would expect means that you have it declared as Public in a module. If that is not the case, then this answer doesn't apply:

    You can access a public variable in a public module of a dll with something like
    <dll name><module name><variable name>

    In fact, you probably don't need the module name. However, you could also make the variable private and provide a method in the dll that returns the variable.

    As for the bit about running the exe from the dll: What does that even mean?
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    292

    Re: Pass a global variable from a dll to a exe??

    Hi!

    The dll and exe are individual seprated and compiled application's .

    i need to pass a variable from a dll application to a exe application, hope you understand what i want here.

    thanks


    Quote Originally Posted by Shaggy Hiker View Post
    You're going to have to explain that a bit better. If a variable is truly global, then you don't need to pass it anywhere. Therefore, I would assume that you mean that the variable is global to the dll, which I would expect means that you have it declared as Public in a module. If that is not the case, then this answer doesn't apply:

    You can access a public variable in a public module of a dll with something like
    <dll name><module name><variable name>

    In fact, you probably don't need the module name. However, you could also make the variable private and provide a method in the dll that returns the variable.

    As for the bit about running the exe from the dll: What does that even mean?

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    292

    Re: Pass a global variable from a dll to a exe??

    anyone?

  5. #5
    Junior Member
    Join Date
    May 2009
    Location
    Buffalo, NY
    Posts
    30

    Re: Pass a global variable from a dll to a exe??

    How secure does this need to be? Does the dll actually execute the executable, or is that a seperate process? If it doesn't need to be very secure, and if the dll exec's the executable, can you pass it as a command line parameter?
    Using VB 2010/2008/2005 (Windows and ASP)

  6. #6
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: Pass a global variable from a dll to a exe??

    There is no such thing as a dll application. A dll is loaded by a .exe

    Your post still does not make sense. They are seperate files on disk yes, but how do you want them to communicate. Does the .exe load the .dll ? Is the .dll loaded by another .exe and you want to pass info to a running .exe or start a new copy of the .exe?

    If you want to pass data to an existing .exe, it needs to know how to accept it. You can't just pass data into something else that is running and expect it to deal with it.
    If you are starting a new .exe then go for passing in command parameters.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    292

    Re: Pass a global variable from a dll to a exe??

    HI!

    Yes the dll executes the exe.
    How do i pass it as a command line parameter?
    what is the code to execute the exe from the dll?


    Quote Originally Posted by ckennedy79 View Post
    How secure does this need to be? Does the dll actually execute the executable, or is that a seperate process? If it doesn't need to be very secure, and if the dll exec's the executable, can you pass it as a command line parameter?

  8. #8
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: Pass a global variable from a dll to a exe??

    What you want to use is the Process class, and there is an example of how to use it here

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    292

    Re: Pass a global variable from a dll to a exe??

    about command line parameter? what do i have to do?

    can someone give-me a example code?

    Quote Originally Posted by Grimfort View Post
    What you want to use is the Process class, and there is an example of how to use it here

  10. #10
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: Pass a global variable from a dll to a exe??

    You can see an example of the parameters in that link:

    Code:
    startInfo.Arguments = "www.northwindtraders.com"
    You would need something like this:

    Code:
    startInfo.Arguments = "/MyInfo=" & MyDataString
    Then in your other app, you can read the arguments using the example shown here

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