system tray icons lost if explorer shuts down/re-starts

Visual Basic

    Next

  • 1. SetParent API cannot set focus - Solved
    I solved the problem by using cursor API's to set the focus to the child window and then using keyboard events to send the data. Bob Hiller Lifts for the Disabled LLC "Bob and Sharon Hiller" < XXXX@XXXXX.COM > wrote in message news: XXXX@XXXXX.COM ... >I use the SetParent API to run Notepad and other applications in a VB >PictureBox. Everything works fine except that I cannot find anyway to set >focus to NotePad through code. The only way is by clicking on it. Is it >possible to set focus to a program running in a child window? > > Thanks, > Bob Hiller > Lifts for the Disabled LLC >
  • 2. Identify a file type and open the file
    Hi All, I want to write C# code to identify a file type and open the file in the associated editor. For example, text files should be identified and opened in notepad, html should be opened in internet explorer/netscape/mozilla. At design time, I do not know if internet explorer/netscape is installed on the client machine. The C# code should identify that and open. Please help. Regards, Shilpa
  • 3. Scheduled Task
    It is possible to generate a task programmed assigning a user, domain and password?
  • 4. Help on use StgOpenStorageEx
    Hi, I would like to use IMAPI to develop an application that burns CDs. At the site vbaccelerator.com I've found a good IMAPI wrapper; but to use it in burning data (Joliet) on CD, it's necessary to provide an IStorage implementation. It seems that this IStorage interface is provided by the StgOpenStorageEx (Ole32.dll), but it's very hard to call this function from VB. Can someone help me ? Thanks Adriano

system tray icons lost if explorer shuts down/re-starts

Postby Pedro CR » Sun, 13 Feb 2005 15:14:48 GMT

hi

i have an app that places an icon in the system tray and the main form can 
only be shown by clicking the icon in the systray.
the app ensures that it's the only instance running to prevent having 
multiple icons in the system tray for the same purpose

however i have a problem: if for any reason windows explorer is terminates, 
when it re-starts the icon is no longer in the system tray but the app is 
still running.
Users complain that they must reboot to get the program working again.
i've noticed that some software is able to recover from this problem and as 
soon as windows explorer re-starts some icons re-appear.

must i use some hack when I add the app to the system tray? I'm using the 
regular NIM_ADD with flags "NIF_ICON Or NIF_MESSAGE Or NIF_TIP".
is there any way to work around this issue?

thanks
pedro



Re: system tray icons lost if explorer shuts down/re-starts

Postby Tom Esh » Sun, 13 Feb 2005 16:20:34 GMT

On Sat, 12 Feb 2005 06:14:48 -0000, "Pedro CR"




Yes. When the shell re-starts it broadcasts the "TaskbarCreated"
registered message and tray apps should respond by re-initializing
(adding) whatever tray icons. Use the RegisterWindowMessage Api
function at runtime to obtain the actual message value, and add a
handler for it in your subclassed winproc.

I believe the "Tray" example at  http://www.**--****.com/ 


-Tom
MVP - Visual Basic
(please post replies to the newsgroup)

Similar Threads:

1.System tray icon does not always show when starting app when Windows starts

I am using VS2005 (vb) and I have a program that starts when Windows boots 
up.  Occasionally the icon that should appear in the system tray does not 
show up.  The program is still running in memory but the tray icon is not 
there.  If I start the program after Windows has booted up the icon shows 
every time.  I am assuming that the reason is due to the icon being created 
before the system tray is loaded/running.   I have used a timer with "dim 
notifyicon1 as new notifyicon" every few seconds and that works but I am 
afraid I am eating up memory doing that or is that "ok" to do?

Is there any way to detect if the system tray is not running so I can delay 
the creation of the tray icon until it is?


2.Remove Express Edition Tray icon from System Tray,...

3.Shut down the system in vb.net 2003

Hi,

I want to shut down my xp/server 2003 system throu code, can any one help
me.


Hardik Shah


4.shut-down Operating System Question

Hi
I have a VB.Net windows application that for some reason when running will 
not allow the user to shut-down/reboot the Operating System without first 
closing my application.  Has anyone had the problem and how might I resolve 
it?

I need my app to allow the user to shut-down and or reboot their OS without 
closing my application first.

Thanks
BrianDH

5.problem shutting systems down when user no logged in

I am trying shut down work stations that are left on over night. This
works great when a user is logged in or the machine is locked but fails
miserably when no body is using the work
station, the programme starts but does not execute.  The program below
runs ok right down to  shut down call then fails,

any help will be gratefully received


Imports System
Imports System.Runtime.InteropServices

Module Module1
    Sub Main()
        Shutdown()
    End Sub
    ' Constants
    Const SE_PRIVILEGE_ENABLED As Integer = &H2
    Const TOKEN_QUERY As Integer = &H8
    Const TOKEN_ADJUST_PRIVILEGES As Integer = &H20
    Const SE_SHUTDOWN_NAME As String = "SeShutdownPrivilege"
    ' Exit Windows Constants
    Const EWX_LOGOFF As Integer = &H0
    Const EWX_SHUTDOWN As Integer = &H1
    Const EWX_REBOOT As Integer = &H2
    Const EWX_FORCE As Integer = &H4
    Const EWX_POWEROFF As Integer = &H8
    Const EWX_FORCEIFHUNG As Integer = &H10
    'Structure
    <StructLayout(LayoutKind.Sequential, Pack:=1)> _
     Friend Structure Luid
        Public Count As Integer
        Public Luid As Long
        Public Attr As Integer
    End Structure 'TokPriv1Luid
    ' Lock Workstation
    <DllImport("user32.dll", ExactSpelling:=True)> _
    Function LockWorkStation() As Boolean
    End Function
    ' Get Current Processes
    <DllImport("kernel32.dll", ExactSpelling:=True)> _
    Function GetCurrentProcess() As IntPtr
    End Function
    ' Open Process Token
    <DllImport("advapi32.dll", SetLastError:=True)> _
    Function OpenProcessToken(ByVal h As IntPtr, ByVal acc As Integer,
ByRef phtok As IntPtr) As Boolean
    End Function
    ' Look up Priviledge Value
    <DllImport("advapi32.dll", SetLastError:=True)> _
    Friend Function LookupPrivilegeValue(ByVal host As String, ByVal
name As String, ByRef pluid As Long) As Boolean
    End Function
    ' Adjust Token Priviledges
    <DllImport("advapi32.dll", ExactSpelling:=True,
SetLastError:=True)> _
    Friend Function AdjustTokenPrivileges(ByVal htok As IntPtr, ByVal
disall As Boolean, ByRef newst As Luid, ByVal len As Integer, ByVal
prev As IntPtr, ByVal relen As IntPtr) As Boolean
    End Function
    ' Exit Windows
    <DllImport("user32.dll", ExactSpelling:=True, SetLastError:=True)>
_
    Friend Function ExitWindowsEx(ByVal flg As Integer, ByVal rea As
Integer) As Boolean
    End Function
    ' Exit Windows Sub
    Private Sub DoExitWindows(ByVal flg As Integer)
        Dim tp As Luid
        Dim hproc As IntPtr = GetCurrentProcess()
        Dim htok As IntPtr = IntPtr.Zero
        OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY,
htok)
        tp.Count = 1
        tp.Luid = 0
        tp.Attr = SE_PRIVILEGE_ENABLED
        LookupPrivilegeValue(Nothing, SE_SHUTDOWN_NAME, tp.Luid)
        AdjustTokenPrivileges(htok, False, tp, 0, IntPtr.Zero,
IntPtr.Zero)
        ExitWindowsEx(flg, 0)
    End Sub
    ' Shutdown
    Public Sub Shutdown()
        DoExitWindows(EWX_SHUTDOWN Or EWX_FORCE)
    End Sub
    ' Restart
    Public Sub Restart()
        DoExitWindows(EWX_REBOOT Or EWX_FORCE)
    End Sub
    ' Log off
    Public Sub LogOff()
        DoExitWindows(EWX_LOGOFF)
    End Sub
    ' Lock Workstation
    Public Sub LockTheComputer()
        LockWorkStation()
    End Sub
End Module

6. How do I Shut Down XP system from Visual Basic 6

7. How to close the system in system tray when the computer shutting down?

8. System tray problem using a custom shell instead of windows explorer



Return to Visual Basic

 

Who is online

Users browsing this forum: No registered users and 4 guest