Re: problem with including .dll into current cpp program

Discussion in 'C++' started by Alex Jin, Jul 2, 2003.

  1. Alex Jin

    Alex Jin Guest

    Actually, there are two methods for linking dll file.
    1. static.
    when linking dll file statically, windows system will be charge of
    loading and unloading dll file. and the location of dll file should be
    windows system folder or the one same as the *.exe file. as your dll file is
    on remote machine, this method can't help you.

    2. dynamic.
    With this method, you will handle loading and unloading dll. it's more
    flexiable than statically linking.

    Suppose the following function in your dll file:
    void dllFoo( char *pStr );

    Please refer to the following for how to use this function:
    /* file: use_dll.cpp */
    #include <stdio.h>
    #include <windows.h>

    typedef void (*Typ_dllFoo)( char *pStr );

    int main()
    {
    HMODULE hDll =
    ::LoadLibrary("\\\\atoc\\admin\\luebeck\\header\\debug\\bccld.dll");
    if ( hDll == 0 )
    {
    printf("load dll fail\n");
    exit(1);
    }

    Typ_dllFoo pFoo = (Typ_dllFoo)::GetProcAddress( hDll, "dllFoo");
    if ( pFoo == 0 )
    {
    ::FreeLibrary( hDll );
    printf("get function address failed\n");
    exit(1);
    }

    pFoo( "hello! that's ok!!" );
    pFoo = 0;

    ::FreeLibrary( hDll );
    return 0;
    }

    That's all !
    Alex Jin.



    "Bharath" <> wrote in message
    news:...
    > Hallo,
    > I am having problem with including .dll file into current cpp
    > program.Actually i have .dll file in our company server.
    > example..the file is in this location ..
    > //atoc/admin/luebeck/header/debug/bccld.dll
    >
    > then my problem is how i have to include this into the current cpp
    > program and i should call some header file ,like dynamictable.h, in
    > that dll.so please help me how to solve this problem.
    >
    > thankiny you,
    > Bharath Kumar
    Alex Jin, Jul 2, 2003
    #1
    1. Advertising

  2. Alex Jin

    Jack Klein Guest

    On Wed, 2 Jul 2003 17:14:26 +0800, "Alex Jin" <>
    wrote in comp.lang.c++:

    Please don't top post. Material you add goes after quoted material
    you are responding to.

    > Actually, there are two methods for linking dll file.


    Please don't pollute comp.lang.c++ with off-topic answers.

    Please cite the sections from the C++ language standard that define
    these two methods for linking "dll" file. Or that specify linking or
    "dll" at all.

    If you can't, the appropriate response is to direct the OP to a proper
    compiler-specific support group.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c /faq
    Jack Klein, Jul 2, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DrUg13
    Replies:
    1
    Views:
    459
    DrUg13
    Feb 10, 2004
  2. Alex Vinokur
    Replies:
    7
    Views:
    396
    Greg Comeau
    Nov 15, 2004
  3. Vinu
    Replies:
    9
    Views:
    593
  4. www.hitechskill.com
    Replies:
    0
    Views:
    1,323
    www.hitechskill.com
    Apr 9, 2006
  5. none
    Replies:
    3
    Views:
    1,078
    Michael Tsang
    Mar 9, 2010
Loading...

Share This Page