node-activex icon indicating copy to clipboard operation
node-activex copied to clipboard

[Question] How to get the process ID of the new activeXObject ?

Open Taxman972 opened this issue 6 years ago • 5 comments

Hi,

When there are 2 processes running with the same name how can I get the PID for each ?

var proc1 = new ActiveXObject("PowerPoint.Application");
var proc2 = new ActiveXObject("PowerPoint.Application");

So far I tried proc1.Quit(); but it doesn't works some time so I would like to get the PId and then call "taskkill /F /T /PID " + proc1.pid

Taxman972 avatar Aug 23 '19 12:08 Taxman972

PID value is unknown, calling WinAPI CoCreateInstance does not give this. You need to free all links to each object and variant from this context.

пт, 23 авг. 2019 г. в 15:23, Taxman972 [email protected]:

Hi,

When there are 2 processes running with the same name how can I get the PID for each ?

var proc1 = new ActiveXObject("PowerPoint.Application"); var proc2 = new ActiveXObject("PowerPoint.Application");

So far I tried proc1.Quit(); but it doesn't works some time so I would like to get the PId and then call "taskkill /F /T /PID " + proc1.pid

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/durs/node-activex/issues/53?email_source=notifications&email_token=AAEMMNPTZUMKU5XNMTBK7DDQF7JCXA5CNFSM4IO7CH4KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HHA5MRQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEMMNNGASZP43OHMEOONHTQF7JCXANCNFSM4IO7CH4A .

durs avatar Aug 24 '19 15:08 durs

You need to free all links to each object and variant from this context.

Do you mean winax.release(proc1) ? Cause that doesn't works either.

var App = new winax.Object("PowerPoint.Application");
var Docs = App.Presentations;
var Doc = Docs.Open("full/path/to/powerpointFile.ppt");

Doc.Save();
Doc.Close();
App.Quit();
winax.release(App, Docs, Doc);

With this code the PowerPoint process is still running.

Taxman972 avatar Sep 12 '19 12:09 Taxman972

Is there a solution to this? (have the same Problem)

sp3rk avatar Feb 17 '20 14:02 sp3rk

I am having the same problem releasing my dlls as well.

crypticspawn avatar Feb 24 '20 16:02 crypticspawn

let ffi = require('ffi-napi'), 
ref = require('ref-napi'),lpdwordPtr = ref.refType(ref.types.ulong), 
user32 = ffi.Library('user32', {GetWindowThreadProcessId: ['int', ['int', lpdwordPtr]]}), 
pid = ref.alloc(lpdwordPtr);
function killHwnd(Hwnd) {
    user32.GetWindowThreadProcessId(Hwnd, pid);
    try { process.kill(pid.readInt32LE(0)) } catch (e) {
        console.warn('process.kill', e);
    }
}

killHwnd(proc1.hwnd); killHwnd(proc2.hwnd);

huhuime avatar Jul 11 '21 09:07 huhuime