How to export a class in a dynamic dll
-
Hi, I have created a function and a class in a DLL. I want to write a .DEF file instead using __declspec(dllexport) and __declspec(dllimport). I wrote the .DEF file like this.. LIBRARY "Sample.dll" //dll name is Sample.dll EXPORTS Multiply @1 //it is the function name CRectArea @2 //it is the class name and this class contains a //method called subtract Please say how to export that function. and I wrote a client program which uses that dll dynamically. //written globally in the implementation file of client typedef int (CALLBACK* LPFNMLTPLY)(int,int); //** I don't know how to declare that function from the class CRectArea HINSTANCE hClcltr=LoadLibrary("DefExported.dll"); LPFNMLTPLY lpfnMuliply; lpfnMuliply = (LPFNMLTPLY)GetProcAddress(hClcltr,"Multiply"); m_Rslt=lpfnMuliply(m_PartOne,m_PartTwo); //m_Rslt will be displayed //in the message box. FreeLibrary( hClcltr ); //now I want to use the function from class Please can anybody help me. Thanks inadvance.
-
Hi, I have created a function and a class in a DLL. I want to write a .DEF file instead using __declspec(dllexport) and __declspec(dllimport). I wrote the .DEF file like this.. LIBRARY "Sample.dll" //dll name is Sample.dll EXPORTS Multiply @1 //it is the function name CRectArea @2 //it is the class name and this class contains a //method called subtract Please say how to export that function. and I wrote a client program which uses that dll dynamically. //written globally in the implementation file of client typedef int (CALLBACK* LPFNMLTPLY)(int,int); //** I don't know how to declare that function from the class CRectArea HINSTANCE hClcltr=LoadLibrary("DefExported.dll"); LPFNMLTPLY lpfnMuliply; lpfnMuliply = (LPFNMLTPLY)GetProcAddress(hClcltr,"Multiply"); m_Rslt=lpfnMuliply(m_PartOne,m_PartTwo); //m_Rslt will be displayed //in the message box. FreeLibrary( hClcltr ); //now I want to use the function from class Please can anybody help me. Thanks inadvance.
The only way to import a class from a dll is by implicit linking (so, without using LoadLibrary and GetProcAddress but using the lib file supplied with the DLL).
Cédric Moonen Software developer
Charting control [v1.1] -
Hi, I have created a function and a class in a DLL. I want to write a .DEF file instead using __declspec(dllexport) and __declspec(dllimport). I wrote the .DEF file like this.. LIBRARY "Sample.dll" //dll name is Sample.dll EXPORTS Multiply @1 //it is the function name CRectArea @2 //it is the class name and this class contains a //method called subtract Please say how to export that function. and I wrote a client program which uses that dll dynamically. //written globally in the implementation file of client typedef int (CALLBACK* LPFNMLTPLY)(int,int); //** I don't know how to declare that function from the class CRectArea HINSTANCE hClcltr=LoadLibrary("DefExported.dll"); LPFNMLTPLY lpfnMuliply; lpfnMuliply = (LPFNMLTPLY)GetProcAddress(hClcltr,"Multiply"); m_Rslt=lpfnMuliply(m_PartOne,m_PartTwo); //m_Rslt will be displayed //in the message box. FreeLibrary( hClcltr ); //now I want to use the function from class Please can anybody help me. Thanks inadvance.
To export/import a class I believe you have to use __declspec(dllexport) and __declspec(dllimport). Mark
-
Hi, I have created a function and a class in a DLL. I want to write a .DEF file instead using __declspec(dllexport) and __declspec(dllimport). I wrote the .DEF file like this.. LIBRARY "Sample.dll" //dll name is Sample.dll EXPORTS Multiply @1 //it is the function name CRectArea @2 //it is the class name and this class contains a //method called subtract Please say how to export that function. and I wrote a client program which uses that dll dynamically. //written globally in the implementation file of client typedef int (CALLBACK* LPFNMLTPLY)(int,int); //** I don't know how to declare that function from the class CRectArea HINSTANCE hClcltr=LoadLibrary("DefExported.dll"); LPFNMLTPLY lpfnMuliply; lpfnMuliply = (LPFNMLTPLY)GetProcAddress(hClcltr,"Multiply"); m_Rslt=lpfnMuliply(m_PartOne,m_PartTwo); //m_Rslt will be displayed //in the message box. FreeLibrary( hClcltr ); //now I want to use the function from class Please can anybody help me. Thanks inadvance.
VC wizard can help you to create a dll class in a second - that is a perfect sample.
-
Hi, I have created a function and a class in a DLL. I want to write a .DEF file instead using __declspec(dllexport) and __declspec(dllimport). I wrote the .DEF file like this.. LIBRARY "Sample.dll" //dll name is Sample.dll EXPORTS Multiply @1 //it is the function name CRectArea @2 //it is the class name and this class contains a //method called subtract Please say how to export that function. and I wrote a client program which uses that dll dynamically. //written globally in the implementation file of client typedef int (CALLBACK* LPFNMLTPLY)(int,int); //** I don't know how to declare that function from the class CRectArea HINSTANCE hClcltr=LoadLibrary("DefExported.dll"); LPFNMLTPLY lpfnMuliply; lpfnMuliply = (LPFNMLTPLY)GetProcAddress(hClcltr,"Multiply"); m_Rslt=lpfnMuliply(m_PartOne,m_PartTwo); //m_Rslt will be displayed //in the message box. FreeLibrary( hClcltr ); //now I want to use the function from class Please can anybody help me. Thanks inadvance.
Did you see examples of dll on codeproject for export class
WhiteSky
-
Did you see examples of dll on codeproject for export class
WhiteSky
Yes Mr.whitesky I practiced the samples and while practicing I got the about. Anyhow thank you very much all of YOU.
-
Yes Mr.whitesky I practiced the samples and while practicing I got the about. Anyhow thank you very much all of YOU.
I glad you find it:)
WhiteSky