excel - GetWindowThreadProcessId method return 0 in c# Console Application -
i using c# console application fetch process id of excel using getwindowthreadprocessid
method. when test on machine fetches proper process id, when deploy application on machine, in .net setup not installed, runs gets 0 id.
please me proper process id of excel instance.
[dllimport("user32.dll")] static extern int getwindowthreadprocessid(int hwnd, out int lpdwprocessid); process getexcelprocess(excel.application excelapp) { int id; getwindowthreadprocessid(excelapp.hwnd, out id); return process.getprocessbyid(id); }
Comments
Post a Comment