dllexport

Discussion in 'C++' started by Cengiz, Jun 26, 2003.

  1. Cengiz

    Cengiz Guest

    Hi,

    i've created DLL with VC++ 6.0 with the following code.

    --------------------------------------------------
    int __declspec(dllexport) initialize(void)
    {
    MessageBox(0,"TEST","TEST",0);
    return 0;
    }
    --------------------------------------------------


    In another project i call this method.
    --------------------------------------------------
    typedef int (*INITIALIZE) ( void );
    INITIALIZE initialize;

    HINSTANCE hDLL = NULL;
    if( hDLL == NULL )
    {
    hDLL = LoadLibrary( "Test2" );
    if (hDLL == NULL)
    {
    MessageBox(0, "Test2.dll not found!", "", 0 );
    return FALSE;
    }

    if(!(initialize = (INITIALIZE)GetProcAddress(hDLL, "initialize")))
    MessageBox(0, "ERROR", "initialize", 0 );
    else initialize();

    FreeLibrary( hDLL );
    hDLL = NULL;
    }
    --------------------------------------------------

    GetProcAddress fails, initialize could not be found.

    What i'm doing wrong ?
     
    Cengiz, Jun 26, 2003
    #1
    1. Advertising

  2. Cengiz

    Boban Guest

    > What i'm doing wrong ?

    Posting to wrong newsgroup. This is MSVC-specific question. Try
    news.microsoft.com server.
     
    Boban, Jun 26, 2003
    #2
    1. Advertising

  3. "Cengiz" <> wrote in message
    news:...
    > Hi,
    >
    > i've created DLL with VC++ 6.0 with the following code.
    >
    > --------------------------------------------------
    > int __declspec(dllexport) initialize(void)
    > {
    > MessageBox(0,"TEST","TEST",0);
    > return 0;
    > }
    > --------------------------------------------------
    >
    >
    > In another project i call this method.
    > --------------------------------------------------
    > typedef int (*INITIALIZE) ( void );
    > INITIALIZE initialize;
    >
    > HINSTANCE hDLL = NULL;
    > if( hDLL == NULL )
    > {
    > hDLL = LoadLibrary( "Test2" );
    > if (hDLL == NULL)
    > {
    > MessageBox(0, "Test2.dll not found!", "", 0 );
    > return FALSE;
    > }
    >
    > if(!(initialize = (INITIALIZE)GetProcAddress(hDLL, "initialize")))
    > MessageBox(0, "ERROR", "initialize", 0 );
    > else initialize();
    >
    > FreeLibrary( hDLL );
    > hDLL = NULL;
    > }
    > --------------------------------------------------
    >
    > GetProcAddress fails, initialize could not be found.
    >
    > What i'm doing wrong ?


    This is certainly off-topic here.

    But a possible reason is that the exported function name has been
    mangled. You need either a def file or an extern C declaration. Talking more
    about them
    here would be certainly more off topic :).
     
    Josephine Schafer, Jun 26, 2003
    #3
  4. "Cengiz" <> wrote...
    > i've created DLL with VC++ 6.0 with the following code.
    >
    > --------------------------------------------------
    > int __declspec(dllexport) [...Microsoft-specific code snipped...]
    > --------------------------------------------------
    >
    > GetProcAddress fails, initialize could not be found.
    >
    > What i'm doing wrong ?


    You're posting to a wrong newsgroup. Find an appropriate one
    whose name starts with 'microsoft.'

    Victor
     
    Victor Bazarov, Jun 26, 2003
    #4
    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. Replies:
    3
    Views:
    1,392
    JH Trauntvein
    Mar 4, 2006
Loading...

Share This Page