使用 process.start 在 vb.net 中调用 .exe 不显示 Windows 通知



我有一个 vb.net 程序,它调用了一个.exe Process.start()关于此.exe的简短摘要:它从Web服务器下载文件,并在下载开始时发送一些Windows通知。如果我只是启动我的"LiveUpdate.exe"文件,这个算法工作正常。

这是我在 vb.net 代码中的调用:

Process.Start(location & "LiveUpdate.exe", "-f "settings.ini")

这是我的 c# 通知方法

public void Popup(string title, string description, Icon systemIcon, ToolTipIcon icon = ToolTipIcon.Info)
        {
            var notification = new NotifyIcon()
            {
                Visible = true,
                Icon = systemIcon, //SystemIcons.Information,
                BalloonTipIcon = icon,
                BalloonTipTitle = title,
                BalloonTipText = description
            };
            Task.Run(() => OpenAndCloseNotification(notification, 2));
        }
        public void OpenAndCloseNotification(NotifyIcon notification, int secconds)
        {
            var milisecconds = secconds * 1000;
            notification.ShowBalloonTip(milisecconds);
            Thread.Sleep(milisecconds);
            notification.Dispose();
        }

说 vb.net 不允许弹出 Windows - 通知?如果您需要,我会附加更多代码,提前感谢您。

这就是它的外观,您可以更改背景图像并删除透明胶片。如果不这样做,请选择具有纯背景的背景,以便将该颜色设置为透明,并且仅保留中心图像的形状。

<blockquote class="imgur-embed-pub" lang="en" data-id="a/V2WnhOA"><a href="//imgur.com/V2WnhOA"></a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>


     Private x, y As Integer
    Private fondo As Image
    Private icono As Icon
    Private WithEvents temporizador As Timer
    Private inicio As DateTime
    Private tiempo As Integer

    Private Sub FNotifi_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim destination = New Bitmap(Size.Width, Size.Height)
        Dim original = Image.FromFile(".ResourcesImagenesFondo1_2.bmp")
        Using g = Graphics.FromImage(destination)
            g.InterpolationMode = InterpolationMode.NearestNeighbor
            g.DrawImage(original, New Rectangle(0, 0, destination.Width, destination.Height), New Rectangle(0, 0, original.Width, original.Height), GraphicsUnit.Pixel)
        End Using

        Dim bmp As Bitmap
        ' bmp = New Bitmap(".ResourcesImagenesFondo1_2.bmp")
        bmp = New Bitmap(destination)
        'el color del pixel(1,1) (esquina sup. izda.) del Bitmap será renderizado
        'como transparente en el Bitmap (color RGB 255,0,0)
        'bmp.MakeTransparent(bmp.GetPixel(1, 1))
        'colocar el Bitmap como fondo del formulario
        Me.BackgroundImage = bmp
        'el color del pixel(1,1) (esquina sup. izda.) del Bitmap será renderizado
        'como transparente también en el formulario (color RGB 255,0,0)
        Me.TransparencyKey = bmp.GetPixel(1, 1)
        Me.BackgroundImageLayout = ImageLayout.Zoom
        Dim workingArea As Rectangle = Screen.GetWorkingArea(Me)
        x = workingArea.Right - Size.Width
        y = workingArea.Bottom - Size.Height
        Me.Location = New Point(x, y)
    End Sub
    Public Sub New(Titulo As String, mensaje As String, ByRef tempo As Timer, Optional tiempo As Integer = 10000)
        ' Esta llamada es exigida por el diseñador.
        InitializeComponent()
        inicio = Now
        temporizador = tempo
        Me.tiempo = tiempo
        LblTitulo.Text = Titulo
        LblMensaje.Text = mensaje
    End Sub
<blockquote class="imgur-embed-pub" lang="en" data-id="a/BW171wJ"><a href="//imgur.com/BW171wJ"></a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>

<blockquote class="imgur-embed-pub" lang="en" data-id="a/BW171wJ"><a href="//imgur.com/BW171wJ"></a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>

自 windows10 以来,我在 Windows 通知方面也遇到了许多问题。我不知道这取决于什么,但有时有效,而其他人则不行。

您是否尝试直接在 CLIC 的按钮事件上显示通知?至少这样你会检查它是否有效。

无论如何,我最后要做的就是创建自己的通知,并在规定的时间内在桌子的角落显示一个表单。

如果你对这个解决方案感兴趣,我会告诉你代码

最新更新