Link between a dll and an exe..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • divyabe
    New Member
    • Oct 2006
    • 2

    Link between a dll and an exe..

    hi,
    i have a dll written in C language
    and have some global variables.

    If i connect the dll from an exe, and applying some operations like addition, multiplication on the global variable and completd the operation
    then again in the same exe, may be somewhere i am again calling the dll and using addition...
    but in the second time i couldnt get the initial value for the global variables. the value will be the last performed operations result value.
    so how can i initialize the variable whenever i call the dlll functions?

    and if use dll, we need their .lib files also?
    why we need this .lib file?
    please clarify my doubts..
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    First in answer to
    and if use dll, we need their .lib files also?
    why we need this .lib file?
    please clarify my doubts..
    The .lib is used when you link you exe file, that is the only time it is needed it provides vectored calls(i.e. non-direct) to the functions in the DLL.


    Onto your problem, the memory in a DLL appears in your programs EXE virtual memory address space. If you want the global variables inside your DLL reinitialised under certain conditions then you will have to provide a function to perform that task.

    If you want them reinitialised everytime you call the function that uses them then you probably shouldn't be using global variables since you are using them in a local context. Use of global variables like that makes the library functions non-reentrant.

    Comment

    Working...