开发者

Calling member function declared in another dll

I have created CMyClass,in which defined one method CallMe().when I build this project MyProject.dll is generated. Now开发者_如何学C in some another project, I want to call CallMe of CMyClass . can anybody tell me how to do it ? Thanks in advance....


You should add a reference to the MyProject.dll to your new project,then, create an object of CMyClass: CMyClass mClass=new CMyClass(); mClass.CallMe();

  • Be sure that the CMyClass class is a public class and the Callme() method is also public


Assuming this is in visual studio..

You need to add a reference to your library from your project, once you have done this you can create an instance of your class and call your method, providing that the class and method is public (or protected if deriving from).

You should be able to do something like :

Yournamespace.CMyClass myClass = new Yournamespace.CMyClass();
myClass.CallMe();


Edit: In C++ just #include the header file and include the .lib file while linking. Or call LoadLibrary to load the DLL. This MSDN page will give you more details.

This is assuming it's not a COM DLL, if it is, things would be somewhat different.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜