1. Use Microsoft Visual C ++ 6 to open visual c ++
2. Select "new" in the "file" menu. A dialog window is displayed. In the dialog window, select a project, select "MFC Appwizard (DLL)", and enter the Project name: "Demo", click OK;
Note: You can select "Win32 dynamic-Link Library" instead of "MFC Appwizard (DLL)", but in this case, you cannot use the "cstring" type, the "cstring" type is a simple MFC type for application.
3. When another dialog window appears, select static. Do not select share. Press "finish" to confirm. Then, an information window will pop up and press "OK ".
4. Congratulations! You have created a project file named "Demo". You can start to write your own DLL code, which supports the MFC code.
5. In the demo. cpp file, you can see a comment. Copy the comment and put it at the end of the file, and modify it by yourself:
// For example:
//
// Extern "C" bool Pascal export exportedfunction ()
//{
// Afx_manage_state (afxgetstaticmodulestate ());
/// Normal function body here
//}
6. After modification, see:
Extern "C" Void Pascal export fun1 ()
{
Afx_manage_state (afxgetstaticmodulestate ());
// Normal function body here
Afxmessagebox ("hello ");
}
7. Add a row at the end of demo. Def: fun1
8. Compile
9. Generate the DLL file in debug and copy it to experts \ libraries in mt4.
10. Create a script in mt4 for testing:
# Import "demo. dll"
Void fun1 ();
# Import
---------------------------------------------------------- +
Int start ()
{
Fun1 ();
Return (0 );
}
11. Run the script. the dialog box "hello" is displayed normally.