Thread: Importing a dll

    #1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2002
    Location
    Seattle WA
    Posts
    863
    Rep Power
    14

    Importing a dll


    I'm sorta new to dlls, or more explicitly, how to use them. In my program, I have a line:
    Code:
    #import <msxml3.dll>
    which obviously imports the Microsoft XML Parser. Now what exactly does this do? Does the pre-processor directive literally import all the classes and methods, such that the dll file is not needed to run the program? Or does it just allow the program to link to the dll, and it's still required?

    Turns out, everyone who uses my program will have the dll, but I'm just not sure what's happening here, and I'd like to know.

    -mj
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,643
    Rep Power
    4247
    The #import statement is used to import a type library. Basically, it causes the compiler to create a set of function prototypes and definitions for the type library into a header file. Wrapper functions and Helper classes are also generated by the compiler. The actual code from the DLL is not imported into your compiler, just the function prototypes, so your friends will still need the DLL for your program to work.

    Hope this helps!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2002
    Location
    Seattle WA
    Posts
    863
    Rep Power
    14
    Excellent, thanks.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Location
    Flint, MI
    Posts
    328
    Rep Power
    12
    There's a second step that is generally necessary. Somewhere on your system is a file msxml3.lib that you will need to link against. This .lib file contains the function stubs so that you won't get unresolved references when you link your program.

    The .lib file itself contains the necessary instructions to load the .DLL into memory and access its functions.
    Clay Dowling
    Lazarus Notes
    Articles and commentary on web development
    http://www.lazarusid.com/notes/
  8. #5
  9. No Profile Picture
    Offensive Member
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Location
    in the perfect world
    Posts
    622
    Rep Power
    28
    The library is created when you create the DLL. It is only needed when implicitly linking the DLL.

    Else you can use the Dependancy walker ect and find the functions and then explicitly link using

    GetProcAddress() and LoadLibrary() ect
    The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

    Frank Zappa

IMN logo majestic logo threadwatch logo seochat tools logo