hi,
I have insatlled Visual Studio 2008.How can i create DLL in Project type Visual C++.Since I have not much worked with VS2008, I would be grateful for help
Printable View
hi,
I have insatlled Visual Studio 2008.How can i create DLL in Project type Visual C++.Since I have not much worked with VS2008, I would be grateful for help
Steps to Create Your DLL
- Create a Win32 Dynamic Link Library project, adding a *. cpp and a *. h file.
- In the *. cpp file, create a class instantiated from the CWinApp file.
- In the *. h file (here it is SourceFile.h), define the functions to be used. Also specify the dllexport value for the _declspec function.
- Then compile the DLL.
- Create a normal Win32 Application with a *. cpp file and a *. h file.
- In the *. h file, (here it is AppHeader.h), declare the function with the dllimport value of _declspec
In the *. cpp file, use the function.
In the Link tab of the "Project-> Settings" dialog, go to the text box labeled "Object / Library Modules" and specify the path of the DLL file. Then copy the compiled DLL file to your current appliation path directory and run the program.Code:# Include "AFXWIN.H"
# Include "AppHeader.h"
class MainFrame: public CFrameWnd
(
public:
Mainframe ()
(
CreateProcess (0, "Trial");
)
OnLButtonDown void (UINT nFlags, CPoint point)
(
int res;
char str [5];
res = Calc (998, 226);
sprintf (str, "% d", res);
MessageBox (str);
)
DECLARE_MESSAGE_MAP ()
);
If you want to create a "managed" (i.e. CLR-based) DLL to be used from C#, I think that you should choose "Class Library" (under Visual C++ / CLR node in the "Project types" tree). This class library will export "managed" (CLR-based) classes, i.e. it will have an object-oriented structure (with classes, methods, etc.)
You can create these classes using C++/CLI extensions to C++ language, and you can use these classes in other .NET languages, including C# and VB.NET.
I had a similar project on the page seen, but this looks promising. Thanks you.