Esempio n. 1
0
    public IntPtr GetHandle()
    {
        StringBuilder lpszFileName     = new StringBuilder(260);
        IntPtr        foregroundWindow = TaskDialogNative.GetForegroundWindow();

        TaskDialogNative.GetWindowModuleFileName(foregroundWindow, lpszFileName, 260U);

        if (Path.GetFileName(lpszFileName.ToString().Replace(".vshost", "")) ==
            Path.GetFileName(Assembly.GetEntryAssembly().Location))
        {
            return(foregroundWindow);
        }

        return(IntPtr.Zero);
    }
Esempio n. 2
0
    public IntPtr GetHandle()
    {
        StringBuilder fileNameSelf     = new StringBuilder(260);
        StringBuilder fileNameActive   = new StringBuilder(260);
        IntPtr        foregroundWindow = TaskDialogNative.GetForegroundWindow();

        TaskDialogNative.GetWindowModuleFileName(foregroundWindow, fileNameActive, 260U);
        TaskDialogNative.GetModuleFileName(IntPtr.Zero, fileNameSelf, fileNameSelf.Capacity);

        if (Path.GetFileName(fileNameActive.ToString().Replace(".vshost", ""))
            == Path.GetFileName(fileNameSelf.ToString()))
        {
            return(foregroundWindow);
        }

        return(IntPtr.Zero);
    }