Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MyApplication_StartupNextInstance not always firing

Status
Not open for further replies.

g33man

Programmer
Dec 22, 2006
50
CA
My app processes files and is called from the right-click context menu from Windows Explorer. The user selects one or more files, right-clicks on the selection, then picks my app from the context menu. The behaviour of Windows is to call the app once for each file in the selection, and the filename is passed as an argument. Since my app is a "single instance application", I need to use the MyApplication_StartupNextInstance event to capture all the filenames selected. It works - most of the time. Every once in a while, it misses a file with no error or explanation. I'll select 4 files in Win Explorer, right-click on my program, and my program only reports on 3 of them. The code in MyApplication_StartupNextInstance is very simple.

Code:
Private Sub MyApplication_StartupNextInstance(sender As Object, e As StartupNextInstanceEventArgs) Handles Me.StartupNextInstance
   For Each s As String In e.CommandLine
      Form1.addFileToList(s)
   Next
End Sub

Looking for a tip from someone who has also seen this (and figured it out). Any troubleshooting tips are also welcome. I've tried some debugging code right at the start of this Sub, and it is definitely not firing when this situation occurs.

Thanks,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top