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.