dllexport

C

Cengiz

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;
}
 
B

Boban

What i'm doing wrong ?

Posting to wrong newsgroup. This is MSVC-specific question. Try
news.microsoft.com server.
 
J

Josephine Schafer

Cengiz said:
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 :).
 
V

Victor Bazarov

Cengiz said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top