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.
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 ()
);
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.
Bookmarks