C/Visual C - Como se añade una dll a un proyecto

 
Vista:

Como se añade una dll a un proyecto

Publicado por Luis (8 intervenciones) el 11/04/2001 11:43:59
Buenas, he instalado los drivers de una tarjeta de E/S que hasta ahora programabamos en MSDOS, pero ahora lo queremos hacer en windows con Visual C++ 5.0 . Tenemos una dll para prograrmarla, pero no sabemos como se añade al proyecto. Muchas gracias por vuestra atencion.
Luis.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Como se añade una dll a un proyecto

Publicado por Emilio (42 intervenciones) el 11/04/2001 12:39:50
You need to create a new MFC DLL wizard project.

1.Start new project.
2.Specify that the project is an MFC
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Como se añade una dll a un proyecto

Publicado por Emilio (42 intervenciones) el 11/04/2001 12:41:55
You need to create a new MFC DLL wizard project.
1.Start new project.
2.Specify that the project is an MFC AppWizard (dll), give the project name and click OK.
3.On the new Window (step 1), choice MFC Extension DLL(using shared MFC DLL), if you need Window Sockets choice Window Sockets.
4.Click FINISH.

Now the Wizard created MFC DLL project and to export class You need to add the macro AFX_EXT_CLASS in the declaration of the classes like:

class AFX_EXT_CLASS CMyClass
{
...
};

To export function you need to add the following to declaration of the function:

extern "C" <function type> PASCAL EXPORT <function declaration>

And you need to call the AFX_MANAGE_STATE macro as the first line of code in all exported functions. This is necessary to make the exported functions threadsafe, because two programs (or threads) can to call one function simultaneously. The AFX_MANAGE_STATE macro receive one parameter, this parameter is a function AfxGetStaticModuleState.
Example to export functions on a DLL:

extern "C" void PASCAL EXPORT MyFunction(...)
{
AFX_MANAGE_STATE (AfxGetStaticModuleState());
//normal function body here
...
}

Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar