durs / node-activex

Node.JS Implementaion of ActiveXObject
MIT License
329 stars 62 forks source link

cannot set properties for objects #133

Closed JackGarner closed 8 months ago

JackGarner commented 8 months ago

Hi everyone! I need to use CAdESCOM.CPSigner object This is how it works in VBS:

Set Certs = Store.Certificates.Find (CAPICOM_CERTIFICATE_FIND_SHA1_HASH, "e1938439a426039f5b159510e7cdf17b0b6fcaef")
Set Cert = Certs.Item (1)
Set Signer = CreateObject ("CADESCOM.CpSigner")
Signer.Certificate = Cert

But when I do the same via winax let oSigner = new ActiveXObject("CAdESCOM.CPSigner");

  1. oSigner.Certificate = cert;- I get an error: Error: Error: DispPropertyPut: Certificate
  2. console.log(oSigner.Certificate);- undefined

But if I set the Options property, it works:

oSigner.Options = 2;
console.log(oSigner.Options); 
outputs 2.

I tried doing it this way: oSigner.__methods.Certificate = cert; This command works, but later the signature is not set correctly.

In the end I achieved the desired result thanks to the commands:

oCert = new winax.Variant(oStore.Certificates.Item(i), 'byref');
oSigner.Certificate = cert;

Can you tell me if I did it right or not? It seems to work, but for some reason I have doubts that I'm doing something wrong....

Thanks in advance!