Two Methods for JavaScript to call com

Source: Internet
Author: User

I used JavaScript to call the com method. It was previously handled because of project requirements. But I didn't think there was anything, so I didn't record anything. I suddenly wanted to find this information yesterday, the result was a little difficult at a time. Now I want to sort it out.

The two call methods are similar. The main difference is how to find the com component. Here we will introduce it:

1. First, use delphi to create a com. This com has a method: function Method1 (const AData: WideString): WideString; to return the passed value.

2. In order to ensure that this com can run, we first created a delphi example to call it through com, which is a button, click here to set the value retrieved from com to the title of the form and test OK. Note: This com can be used only if it has been registered (registered through regsvr32 ), otherwise, the system prompts "not registered". The error "ole" may be prompted when you import com through type. This error is due to the Administrator permission required by com. You can use the Administrator permission to enable delphi.

 procedure TForm1.Button1Click(Sender: TObject); var   o: IDemo; begin    o := CoDemo.Create;    Caption:= o.Method1('123'); end;

3. I have already proved that this dll is correct. Now we can call it through com:

(1)

<Html> 

1C93CD11-2021-4D39-ABA2-FDBBEC655F23 is obtained from

  LIBID_Project1: TGUID = '{DAA74E33-0A12-452A-A0AA-8AA1CE239806}';  IID_IDemo: TGUID = '{DC66EC7C-FA4E-4593-ACB0-92E477F297FD}';  CLASS_Demo: TGUID = '{1C93CD11-2021-4D39-ABA2-FDBBEC655F23}';

(2)

("Project1.Demo") is obtained from the same content as above. After testing, you can see the prompt information.

Related Article

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.