Sender: xxhn (Hunan), email area: mathtools
Title: Re: Problems in mixed programming of MATLAB and VC (called Using IDL or DLL)
Mailing site: BBS shuimu Tsinghua station (Tue Aug 19 15:08:50 2003)
Here we provide a method to call COM components through IDL or DLL (you do not need to generate *. h and *. c files)
In fact, this method is simpler than calling by generating the. h and. c files. The example of the essence zone is also used.
1. Use OLE/COM object to generate the IDL file, add this IDL file to the project, and click build-complie.
Comtest_00000.tlb to generate the TLB File
2. Open classwizard, click Add class-from a Type Library class on the right, and select the generated
Comtest_00000.tlb (should be in the debug \ directory). In fact, you can directly choose to use combuilder of Matlab.
The generated comtest_00000.dll (this saves the first step). Some dialog boxes for generating the class will appear later.
Prompt to do it. In this way, comtest_00000.h and comtest_00000.cpp are generated, and an isgltest is added.
Class :)
3. Test Code As follows:
In the header file, you only need to add:
# Include "comtest_00000.h"
Test code:
Isgltest st;
Afxoleinit ();
If (St. createdispatch (_ T ("comtest. sgltest ")))
{
St. im_test ();
Afxmessagebox ("Haha, succeeded ");
St. releasedispatch ();
}
Else
Afxmessagebox ("unsucceeded ");
For the specific meaning of the above Code, see msdn. I just found out :)
[mentioned in the masterpiece promise0608 (promise0608):]
: When I use the COM component, use the Microsoft Visual Studio tool Ole viewer to open the generated component. Find
: Find the DLL file generated by MATLAB com builder and save it as *. h and *. C. An error occurs!
: I use VC. net. I don't know why!
: Please help me!
: Thank you!