Solved

API (VB6) for Closing a tray icon program

Posted on 2004-10-19
4
304 Views
Last Modified: 2012-08-14
My data provider recently changed their program from a "Windowed application" to just a system tray program.  I used to close the GUI program like this:

   lngWin = FindWindow(vbNullString, "TALNET")
   If lngWin <> 0 Then SendMessage lngWin, WM_CLOSE, 0&, 0&

But that doesn't work anymore because there is no window.  My provider emailed back:

"Using the Win32 SendMessage API was a good idea for an app that had a GUI window, as TALNET did.  Since TALDDE's just a tray icon, the logical analogy would be to find the Win32 API for sending a message to a tray icon"

Can anyone send me the code to close a program that is only running in the system tray?  The program is called "taldde32.exe" in the Processes tab of the Windows Task Manager.

 




0
Comment
Question by:LovinSpoonful
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 500 total points
ID: 12349698
This can be done using WMI as follows:

Dim oProcess

For Each oProcess In GetObject("winmgmts:root\cimv2").ExecQuery("Select * from " & _
                    "Win32_Process Where Name = 'taldde32.exe'")

    oProcess.Terminate
    Debug.Print oProcess.Name & " was terminated..."

Next
0
 
LVL 13

Expert Comment

by:Michael_D
ID: 12349709
Try to find the process using API
Declare Function EnumProcesses Lib "PSAPI.DLL" (ByRef lpidProcess As Long, _
                                                                        ByVal cb As Long, _
                                                                        ByRef cbNeeded As Long) As Long


Then use

Declare Function TerminateProcess Lib "kernel32" Alias "TerminateProcess" (ByVal hProcess As Long, _
                                                                                                               ByVal uExitCode As Long) As Long

to terminate the process
0
 
LVL 13

Expert Comment

by:Michael_D
ID: 12349782
I agree with Erick37
Nice solution!
0
 

Author Comment

by:LovinSpoonful
ID: 12369592
thank you Erick37.  
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question