Debug COM in Delphi7

Source: Internet
Author: User

The biggest headache for developing a com application system is how to debug COM components. Since COM is executed in the execution environment of COM, Delphi programmers cannot set the breakpoint of the application server in Delphi ide just like Delphi's distributed multi-tier application system.

In fact, Delphi can still debug COM components in the integrated development environment of Delphi, or allow programmers to set breakpoints in the program units of COM components in the integrated development environment, then execute the client application to call the COM component. In this case, Delphi will bring the execution control to the integrated development environment of Delphi, and pause the breakpoint set by the programmer to allow the programmer to start debugging. From then on, programmers can call COM components just like debugging common applications. But to debug COM components in this way, programmers must first make some settings.

<? XML: namespaceprefix = ons = "urn: Schemas-Microsoft-com: Office: office"/>

1. Activate the COM component project to be debugged in the integrated development environment of Delphi, click projects | options, select the linker page in the pop-up dialog box, and select includetd32info and javasderemotedebugsymbol;

2. Click RUN | installcom objects menu to register COM components. It is best to register a new application, you can also register an existing application (this application must be generated by the COM program registered by Delphi ).

3. Run Win2000 Control Panel | governance tool | component service. In the com application, right-click the application registered with COM and select the "properties" menu, in the displayed dialog box, select the "advanced" Page and select the "Start In Debugger" option. The following debugging path contains the following content: "C: programfilesborlanddelphi7binordbg70.exe "dllhost.exe/processid: {9cec476d-83a5-4c2b-aff1-3e83a147b866}

4. Return to the integrated development environment of Delphi and click the run | parameters menu. In the dialog box, set hostapplication to C: winntsystem32dllhost. EXE, (set according to your operating system installation ). Parameters is set to/processid: {9cec476d-83a5-4c2b-aff1-3e83a147b866}. The GUID value must be consistent with the property value in the Win2000 Component Service and can be copied directly from there.

5. set breakpoints and run com in the integrated development environment of Delphi;

6. Run the client program that calls COM in Windows (or in the New Delphi environment.

At this time, we will find that COM in the Delphi Development Environment stops at the breakpoint, and then we can track and debug it in a single step.

Debug COM in Delphi7

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.