Mt4 programming-the entire process of DLL Programming

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.