SoFunction
Updated on 2025-03-07

C# Solution to using com to operate excel to release process


//Calling the underlying function to get the process label
    [DllImport("")]
    public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int ProcessId);
    private static void KillExcel( theApp)
    {
        int id = 0;
        IntPtr intptr = new IntPtr();
        p = null;
        try
        {
            GetWindowThreadProcessId(intptr, out id);
            p = (id);
            if (p != null)
            {
                ();
                ();
            }
        }
        catch (Exception ex)
        {

        }
    }