durs / node-activex

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

Supply pointer to an existing instance (e.g. existing instance of Excel) #80

Closed OSjoerdWie closed 4 years ago

OSjoerdWie commented 4 years ago

For my use case I have obtained a pointer already via GetAccessibleObjectFromWindow and wanted my javascript object to be instantiated using that instead of creating a new Excel instance. Please consider adding this. (also relevant wrt #47 )

Since node version was set to >= 4.0.0, I have chosen for the uint8Array. Alternatively, this can be done using a BigInt. (This would require the minimum node major version >= 10, if I am not mistaken)

// Use supplied dispatch pointer
else if (args[0]->IsBigInt()) {
    bool lossless;
    IDispatch* p = (IDispatch *) (Local<BigInt>::Cast(args[0]))->Uint64Value(&lossless);
    disp = CComPtr<IDispatch>(p);
    hrcode = S_OK;
}