Memory error after ActiveX Import

Source: Internet
Author: User
This problem occurs not only when I use Delphi7 in step 5, but also when I use Delphi7. This time, we must make a record, wasting a day to find it.

First, let's take a look at the ActiveX control written by VB in Delphi
5. The following strange performances. For example, we use VB to write a control usertest (for the sake of simplicity, we only export one class, that is, the user control), one property testname, and one method testmethod. Compile it into an ActiveX control, register and import it into the development environment of delphi5 (if the above steps are unclear, please refer to various references and there must be a standard answer ), so far, everything seems normal. Then, we would like to drag and drop the control to the form, adjust the size, assign values to the attribute in the attribute window, or the same in the code, which is normal and easy to use. However, the following problem arises. If you call the testmethod with great interest, you will get an odd exception "Ole
Error 800a01a9 ", and then the program exits. Unfortunately, you will not be able to track this exception, either in Delphi or in VB. Of course, if you are good at assembly, you can proceed step by step with the debugging window of Delphi ...... When I first encountered this problem, I was almost angry because Microsoft or Borland did not explain the error or have any information to search. I had to go to several forums that I often go to. Of course, the most important issue is csdn. I search for similar problems in the VB and Delphi versions. Then I am very sorry that there are only similar problems, there is no answer. A major customer uses this development tool. After testing almost all development tools and development environments (including desktop and web) on windows, but I forgot Delphi. In the remaining two days, I almost ran around the world, called all my friends, asked Delphi experts if they knew the situation, and finally found a link from Google, unfortunately, I forgot the specific location of the link, but I got a almost magic method (the discoverer called it ): you can solve this problem by manually modifying the file of the agent type library xxx_tlb.pas (here XXX refers to the control class name) generated after delphi imports the VB ActiveX control. For example, there is a VB-written control usercontrol1, which generates two files after being imported in Delphi. One of the usercontrolpolictlb.pas is the file we want to modify. Search for fintf: _ usercontrol1; function getcontrolinterface: _ usercontrol1; and property controlinterface: _ usercontrol1 read getcontrolinterface; and procedure alert; Procedure docreate; begin finf: = iunknown (oleobject) AS _ usercontrol1; end; begin if finf = nil then docreate; end; function tusercontrol1.getcontrol1interface: _ usercontrol1; begin createcontrol; Result: = finfl; end; note: _ usercontrol1 marked in red must be replaced _
Usercontrol1disp. If the compilation fails, replace all _ usercontrol1 reported in the compilation warning with _ usercontrol1disp. Compile the code so that the above fatal error will not occur when calling the control method. Thanks to this great discovery, I can only describe it like this. Otherwise, I may not be able to cover it in this circle until now, alternatively, you can use another tool to re-develop the control (I can hardly imagine the workload, or it may have other compatibility issues ).

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.