Solved

IntelliPoint settings...

Posted on 2001-08-27
20
406 Views
Last Modified: 2007-12-19
Does anyone know of how to change IntelliPoint settings at run-time... by this I mean change the settings in memory, so that they are immediately available.

For instance, if I wanted to change the function of the right-click button to be the same as F1 (or something like that), is it possible (okay, I know it is possible, as MS can do it with their control panel app).

I think I have isolated where in the registry the permanent settings are stored, but changing these do not change the current settings in memory until reboot.

Any idea???
0
Comment
Question by:taplin
  • 11
  • 8
20 Comments
 
LVL 5

Expert Comment

by:rkot2000
ID: 6429271
i think you can develop an addin for vb and monitor kbrd or mouse
0
 
LVL 2

Author Comment

by:taplin
ID: 6429335
rkot2000... thanks for the idea, but I don't think it gets at what I need.  I need to be able to update the current settings for IntelliPoint as they are in memory; or, I need to refresh the current mouse handler drivers to look at the settings in the registry.

Thank you,
Jay
0
 
LVL 2

Expert Comment

by:ramses
ID: 6429500
Try these 2 urls if you're interesting in (re)programming mouse in VB

http://web.missouri.edu/~finaidtk/mcenter.htm


And should you be interested in (re)programming the Wheel, take a look at this


http://web.missouri.edu/~finaidtk/imcaper.htm


Look for more mouse related info at that site.  I'll bet you'l find an answer there




Ramses
0
 
LVL 2

Expert Comment

by:ramses
ID: 6429509
Another thing.  Do you want these changes to be system-wide or just app-wide?  If so, then just use the Mouse related events of your form and controls


Ramses
0
 
LVL 2

Author Comment

by:taplin
ID: 6429537
ramses:

Thank you for your input also.  However, this still isn't quite what I am looking for.  Let me give a very specific example, as I was probably too vague up top.

With IntelliPoint and the newer mouses, such as the ones with buttons on the left and right sides of the mouse, you can program any of the buttons to do whatever you want, so long as one button is the normal "click" button.  For instance, by default, the button on the left hand side of the mouse is defaulted to "back" in an internet browser, and the button on the right-hand side is defaulted to "forward".  Using the IntelliPoint control panel app, you can change these settings to a set of predefined choices.  For instance, I could change the left-hand side button to CTRL+C, so that every time I click it, text is copied.  I want to be able to reprogram the mouse to be able to do this - system wide.  I want to perform the same functionality as IntelliPoint.

When you change the settings in IntelliPoint and then exit the window, the new changes occur.  My problem is this: I can set the settings in the registry that cause the buttons to change to whatever I want upon reboot, but I cannot figure out how to get IntelliPoint (or the mouse driver, or whatever) to "refresh" itself if I don't want to reboot.

Okay, so that's what I'm trying to do.  I'm going to add some points, as I knew this was going to be a tough one.

Again, thank's to both ramses and rkot2000 for your help thus far!
0
 
LVL 2

Author Comment

by:taplin
ID: 6429540
More points!
0
 
LVL 2

Author Comment

by:taplin
ID: 6429541
Well, I tried to do 500... but I guess 300 is the limit!
0
 
LVL 2

Expert Comment

by:ramses
ID: 6429555
hmm.. I'll look in to it after I finish doing the dishes...
0
 
LVL 2

Expert Comment

by:ramses
ID: 6429633
Should this help, bellow is a list of all registry activity made after pressing the Apply button when changing the Rightbutton assignment from the default to F1 (Help)


Hope this helps

2      Point32      QueryValueEx      0xC184DAA0\PSAPI      NOTFOUND            
3      Point32      OpenKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS      hKey: 0xC1888C80      
4      Point32      QueryValueEx      HKLM\Software\Microsoft\Windows\CurrentVersion\SubVersionNumber      SUCCESS      20 0       
5      Point32      CloseKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS            
6      Point32      OpenKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS      hKey: 0xC1888C80      
7      Point32      QueryValueEx      HKLM\Software\Microsoft\Windows\CurrentVersion\SubVersionNumber      SUCCESS      20 0       
8      Point32      CloseKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS            
9      Point32      QueryValueEx      0xC184DAA0\HID      NOTFOUND            
10      Point32      QueryValueEx      0xC184DAA0\SETUPAPI      NOTFOUND            
11      Point32      QueryValueEx      0xC184DAA0\COMDLG32      SUCCESS      "COMDLG32.DLL"      
12      Point32      QueryValueEx      0xC184DAA0\CFGMGR32      NOTFOUND            
13      Point32      QueryValueEx      0xC184DAA0\RPCRT4      SUCCESS      "RPCRT4.DLL"      
14      Point32      OpenKey      HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Documents      SUCCESS      hKey: 0xC1888C80      
15      Point32      QueryValueEx      HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Documents\DisableStartInMyDocs      NOTFOUND            
16      Point32      QueryValueEx      HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Documents\HideMyDocsFolder      NOTFOUND            
17      Point32      CloseKey      HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Documents      SUCCESS            
18      Point32      OpenKey      HKLM\SYSTEM\Setup      NOTFOUND            
19      Point32      OpenKey      HKLM\Software\Microsoft\Windows\CurrentVersion\Setup      SUCCESS      hKey: 0xC1888C80      
20      Point32      QueryValueEx      HKLM\Software\Microsoft\Windows\CurrentVersion\Setup\SourcePath      SUCCESS            
21      Point32      QueryValueEx      HKLM\Software\Microsoft\Windows\CurrentVersion\Setup\SourcePath      SUCCESS      "F:\SOFTWA~7\WIN98\"      
22      Point32      CloseKey      HKLM\Software\Microsoft\Windows\CurrentVersion\Setup      SUCCESS            
23      Point32      OpenKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS      hKey: 0xC1888C80      
24      Point32      QueryValueEx      HKLM\Software\Microsoft\Windows\CurrentVersion\DevicePath      SUCCESS      "D:\OS\INF"      
25      Point32      CloseKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS            
26      Point32      OpenKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS      hKey: 0xC1888C80      
27      Point32      QueryValueEx      HKLM\Software\Microsoft\Windows\CurrentVersion\SubVersionNumber      SUCCESS      20 0       
28      Point32      CloseKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS            
29      Point32      OpenKey      HKLM\System\CurrentControlSet\Control\DeviceClasses      SUCCESS      hKey: 0xC1888C80      
30      Point32      OpenKey      HKLM\System\CurrentControlSet\Control\CommAlias      NOTFOUND            
31      Point32      QueryValueEx      0xC29A8940\PORTNAME      SUCCESS      "LPT1"      
32      Point32      QueryValueEx      0xC29A8940\FRIENDLYNAME      SUCCESS      "ECP Printer Port (LPT1)"      
33      Point32      QueryValueEx      0xC29B9C80\PORTNAME      SUCCESS      "COM1"      
34      Point32      QueryValueEx      0xC29B9C80\FRIENDLYNAME      SUCCESS      "Communications Port (COM1)"      
35      Point32      OpenKey      HKLM\System\CurrentControlSet\Control\SessionManager\KnownVxDs      NOTFOUND            
36      Point32      CreateKey      HKLM\System\CurrentControlSet\Control\DeviceClasses      SUCCESS      hKey: 0xC1888C80      
37      Point32      CreateKey      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}      SUCCESS      hKey: 0xC188C750      
38      Point32      CloseKey      HKLM\System\CurrentControlSet\Control\DeviceClasses      SUCCESS            
39      Point32      QueryValueEx      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}\@ClassName      NOTFOUND            
40      Point32      QueryKey      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}      SUCCESS      Keys: 0 Values: 0      
41      Point32      CloseKey      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}      SUCCESS            
42      Point32      OpenKey      HKLM\System\CurrentControlSet\Control\CommAlias      NOTFOUND            
43      Point32      QueryValueEx      0xC29A8940\PORTNAME      SUCCESS      "LPT1"      
44      Point32      QueryValueEx      0xC29A8940\FRIENDLYNAME      SUCCESS      "ECP Printer Port (LPT1)"      
45      Point32      QueryValueEx      0xC29B9C80\PORTNAME      SUCCESS      "COM1"      
46      Point32      QueryValueEx      0xC29B9C80\FRIENDLYNAME      SUCCESS      "Communications Port (COM1)"      
47      Point32      OpenKey      HKLM\System\CurrentControlSet\Control\SessionManager\KnownVxDs      NOTFOUND            
48      Point32      CreateKey      HKLM\System\CurrentControlSet\Control\DeviceClasses      SUCCESS      hKey: 0xC1888C80      
49      Point32      CreateKey      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}      SUCCESS      hKey: 0xC182BE60      
50      Point32      CloseKey      HKLM\System\CurrentControlSet\Control\DeviceClasses      SUCCESS            
51      Point32      QueryValueEx      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}\@ClassName      NOTFOUND            
52      Point32      QueryKey      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}      SUCCESS      Keys: 0 Values: 0      
53      Point32      CloseKey      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}      SUCCESS            
54      Point32      OpenKey      0xC1888C80\{4D1E55B2-F16F-11CF-88CB-001111000030}      SUCCESS      hKey: 0xC182BE60      
55      Point32      CloseKey      0xC1888C80\{4D1E55B2-F16F-11CF-88CB-001111000030}      SUCCESS            
56      Point32      CloseKey      0xC1888C80      SUCCESS            
57      Point32      OpenKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS      hKey: 0xC1888C80      
58      Point32      QueryValueEx      HKCU\Control Panel\Microsoft Input Devices\Mouse\MSW_SmartUniversal      SUCCESS      "ON"      
59      Point32      CloseKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS            
60      Point32      OpenKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS      hKey: 0xC1888C80      
61      Point32      SetValueEx      HKCU\Control Panel\Microsoft Input Devices\Mouse\MSW_SmartUniversal      SUCCESS      "ON"      
62      Point32      CloseKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS            
63      Point32      OpenKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS      hKey: 0xC1888C80      
64      Point32      QueryValueEx      HKCU\Control Panel\Microsoft Input Devices\Mouse\MSW_SmartPanning      NOTFOUND            
65      Point32      CloseKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS            
66      Point32      OpenKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS      hKey: 0xC1888C80      
67      Point32      QueryValueEx      HKCU\Control Panel\Microsoft Input Devices\Mouse\MSW_SmartScrolling      NOTFOUND            
68      Point32      CloseKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS            
69      Point32      OpenKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS      hKey: 0xC1888C80      
70      Point32      QueryValueEx      HKCU\Control Panel\Microsoft Input Devices\Mouse\MSW_SmartAutoScroll      NOTFOUND            
71      Point32      CloseKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS            
72      Point32      OpenKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS      hKey: 0xC1888C80      
73      Point32      SetValueEx      HKCU\Control Panel\Microsoft Input Devices\Mouse\TrayIcon      SUCCESS      "FALSE"      
74      Point32      CloseKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS            
75      Point32      OpenKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS      hKey: 0xC1888C80      
76      Point32      SetValueEx      HKCU\Control Panel\Microsoft Input Devices\Mouse\R_BtnAssignment      SUCCESS      0x20      
77      Point32      CloseKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS            
78      Rundll32      OpenKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS      hKey: 0xC1888C80      
79      Rundll32      SetValueEx      HKCU\Control Panel\Microsoft Input Devices\Mouse\DeviceNum      SUCCESS      0x7      
80      Rundll32      CloseKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS            
81      Point32      OpenKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS      hKey: 0xC1888C80      
82      Point32      QueryValueEx      HKLM\Software\Microsoft\Windows\CurrentVersion\SubVersionNumber      SUCCESS      20 0       
83      Point32      CloseKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS            
84      Point32      OpenKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS      hKey: 0xC1888C80      
85      Point32      QueryValueEx      HKLM\Software\Microsoft\Windows\CurrentVersion\SubVersionNumber      SUCCESS      20 0       
86      Point32      CloseKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS            
87      Point32      QueryValueEx      0xC184DAA0\HID      NOTFOUND            
88      Point32      QueryValueEx      0xC184DAA0\SETUPAPI      NOTFOUND            
89      Point32      QueryValueEx      0xC184DAA0\COMDLG32      SUCCESS      "COMDLG32.DLL"      
90      Point32      QueryValueEx      0xC184DAA0\CFGMGR32      NOTFOUND            
91      Point32      QueryValueEx      0xC184DAA0\RPCRT4      SUCCESS      "RPCRT4.DLL"      
92      Point32      OpenKey      HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Documents      SUCCESS      hKey: 0xC1888C80      
93      Point32      QueryValueEx      HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Documents\DisableStartInMyDocs      NOTFOUND            
94      Point32      QueryValueEx      HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Documents\HideMyDocsFolder      NOTFOUND            
95      Point32      CloseKey      HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Documents      SUCCESS            
96      Point32      OpenKey      HKLM\SYSTEM\Setup      NOTFOUND            
97      Point32      OpenKey      HKLM\Software\Microsoft\Windows\CurrentVersion\Setup      SUCCESS      hKey: 0xC1888C80      
98      Point32      QueryValueEx      HKLM\Software\Microsoft\Windows\CurrentVersion\Setup\SourcePath      SUCCESS            
99      Point32      QueryValueEx      HKLM\Software\Microsoft\Windows\CurrentVersion\Setup\SourcePath      SUCCESS      "F:\SOFTWA~7\WIN98\"      
100      Point32      CloseKey      HKLM\Software\Microsoft\Windows\CurrentVersion\Setup      SUCCESS            
101      Point32      OpenKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS      hKey: 0xC1888C80      
102      Point32      QueryValueEx      HKLM\Software\Microsoft\Windows\CurrentVersion\DevicePath      SUCCESS      "D:\OS\INF"      
103      Point32      CloseKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS            
104      Point32      OpenKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS      hKey: 0xC1888C80      
105      Point32      QueryValueEx      HKLM\Software\Microsoft\Windows\CurrentVersion\SubVersionNumber      SUCCESS      20 0       
106      Point32      CloseKey      HKLM\Software\Microsoft\Windows\CurrentVersion      SUCCESS            
107      Point32      OpenKey      HKLM\System\CurrentControlSet\Control\DeviceClasses      SUCCESS      hKey: 0xC1888C80      
108      Point32      OpenKey      HKLM\System\CurrentControlSet\Control\CommAlias      NOTFOUND            
109      Point32      QueryValueEx      0xC29A8940\PORTNAME      SUCCESS      "LPT1"      
110      Point32      QueryValueEx      0xC29A8940\FRIENDLYNAME      SUCCESS      "ECP Printer Port (LPT1)"      
111      Point32      QueryValueEx      0xC29B9C80\PORTNAME      SUCCESS      "COM1"      
112      Point32      QueryValueEx      0xC29B9C80\FRIENDLYNAME      SUCCESS      "Communications Port (COM1)"      
113      Point32      OpenKey      HKLM\System\CurrentControlSet\Control\SessionManager\KnownVxDs      NOTFOUND            
114      Point32      CreateKey      HKLM\System\CurrentControlSet\Control\DeviceClasses      SUCCESS      hKey: 0xC1888C80      
115      Point32      CreateKey      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}      SUCCESS      hKey: 0xC188C750      
116      Point32      CloseKey      HKLM\System\CurrentControlSet\Control\DeviceClasses      SUCCESS            
117      Point32      QueryValueEx      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}\@ClassName      NOTFOUND            
118      Point32      QueryKey      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}      SUCCESS      Keys: 0 Values: 0      
119      Point32      CloseKey      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}      SUCCESS            
120      Point32      OpenKey      HKLM\System\CurrentControlSet\Control\CommAlias      NOTFOUND            
121      Point32      QueryValueEx      0xC29A8940\PORTNAME      SUCCESS      "LPT1"      
122      Point32      QueryValueEx      0xC29A8940\FRIENDLYNAME      SUCCESS      "ECP Printer Port (LPT1)"      
123      Point32      QueryValueEx      0xC29B9C80\PORTNAME      SUCCESS      "COM1"      
124      Point32      QueryValueEx      0xC29B9C80\FRIENDLYNAME      SUCCESS      "Communications Port (COM1)"      
125      Point32      OpenKey      HKLM\System\CurrentControlSet\Control\SessionManager\KnownVxDs      NOTFOUND            
126      Point32      CreateKey      HKLM\System\CurrentControlSet\Control\DeviceClasses      SUCCESS      hKey: 0xC1888C80      
127      Point32      CreateKey      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}      SUCCESS      hKey: 0xC182BE60      
128      Point32      CloseKey      HKLM\System\CurrentControlSet\Control\DeviceClasses      SUCCESS            
129      Point32      QueryValueEx      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}\@ClassName      NOTFOUND            
130      Point32      QueryKey      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}      SUCCESS      Keys: 0 Values: 0      
131      Point32      CloseKey      HKLM\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}      SUCCESS            
132      Point32      OpenKey      0xC1888C80\{4D1E55B2-F16F-11CF-88CB-001111000030}      SUCCESS      hKey: 0xC182BE60      
133      Point32      CloseKey      0xC1888C80\{4D1E55B2-F16F-11CF-88CB-001111000030}      SUCCESS            
134      Point32      CloseKey      0xC1888C80      SUCCESS            
135      Rundll32      OpenKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS      hKey: 0xC1888C80      
136      Rundll32      QueryValueEx      HKCU\Control Panel\Microsoft Input Devices\Mouse\DeviceNum      SUCCESS      0x7      
137      Rundll32      CloseKey      HKCU\Control Panel\Microsoft Input Devices\Mouse      SUCCESS            
138      Point32      QueryValueEx      0xC184DAA0\PSAPI      NOTFOUND            
0
 
LVL 2

Expert Comment

by:ramses
ID: 6429672
Oh yes, I forgot to give you info on the format of the list.


First is a number.  number 4 happens before number 5, then comes the name of the module calling the registry, then the requested action, ie OpenKey, then the Key that is being called, followed by either SUCCESS, NOTFOUND, or NOMORE and lastly, if applicable, the data that is transfered between the registry and the calling module


Ramses
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 2

Expert Comment

by:ramses
ID: 6429681
entrys that call a key in the format like 0x... are not actually caling the registry but an external file, like win.ini
0
 
LVL 2

Author Comment

by:taplin
ID: 6429698
Oh man...

I will be looking at your response, but it's going to have to be tonight or tomorrow morning... that's going to take a bit of time to figure out.  I really appreciate your help!

BTW, how'd you get that info?

Thanks,
Jay
0
 
LVL 2

Expert Comment

by:ramses
ID: 6429722
I use an utility called RegMon (Registry Monitor)


It's free 4 all, to be downloaded from:


http://www.sysinternals.com


Glad to be of service



Ramses
0
 
LVL 2

Author Comment

by:taplin
ID: 6432423
Hey... thanks for the info on the RegMon app.  After looking through all the registry settings, I'm trying a different approach.  I knew of the registry settings IP uses to save the configuration in HKEY_CURRENT_USER\Control Panel\Microsoft Input Devices\Mouse.  I realized that by terminating the point32 process from Task Manager (yes, I know, not recommended, but for the sake of research it works great!), and then reloading point32, the new settings take.

I've posted a question pertaining to the best way to get point32 to terminate from VB.  If you have any thoughts, they would be greatly appreciated.  I'd like to avoid modifying a couple dozen registry settings, as there is too much chance of screwing something up by not knowing the ramifications of changing each setting.

Thanks,
Jay

p.s.  Either way, you get the points for all your help!
0
 
LVL 2

Expert Comment

by:ramses
ID: 6435526
If believe you'd have to 1st obtain the handle of point32 program and then SendMsg WM_CLOSE to that handle

Hold on... I'll look it up

0
 
LVL 2

Accepted Solution

by:
ramses earned 300 total points
ID: 6435546
Here you go, taken from the Microsoft Knowledge Base, http://support.microsoft.com/support/kb/articles/Q176/3/91.ASP?LN=NL&SD=gn&FR=0


HOWTO: Programmatically Close a Separate Application

--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Visual Basic Learning Edition for Windows, versions 5.0, 6.0
Microsoft Visual Basic Professional Edition for Windows, versions 5.0, 6.0
Microsoft Visual Basic Enterprise Edition for Windows, versions 5.0, 6.0

--------------------------------------------------------------------------------


SUMMARY
This article shows you how use API functions to programmatically close a single instance of most Windows programs through your Visual Basic program. You can use this feature to start a program, run the program without any user interaction, and shut down the program when all the program tasks are completed.



MORE INFORMATION
To programmatically close a single instance of a Windows program, you begin by getting the handle to the Window that you want to close with the FindWindow function. The FindWindow API function returns the handle of a top-level window whose class name and window name matches the string parameters. This function returns the handle of the window as a long value if it is successful and a null if it fails. To use this function, you must supply two parameters:


lpClassName - a pointer to a null-terminated string that specifies the class name or is an atom that identifies the class-name string. In this application, you can pass vbNullString.


lpWindowName - a pointer to a null-terminated string that specifies the window name (the window's title).


Use the handle to send a message to close the Window with the PostMessage API. The PostMessage API function sends a message to an application message queue and returns a value immediately. This function returns a non-zero value if the function is successful and zero if the function fails. To use this function, you must specify four parameters:

hWnd - the handle of the window you want to close. This long value is available as the result of the FindWindow function.


uInt - the message to post to the message queue. In this application, you would use the WM_CLOSE message.


wParam - the first message parameter. For this message, you should pass a null value.


lParam - the second message parameter. For this message, you should pass a null value.


A synchronization problem can occur when you send a message to close in the event and the program terminates before the message is processed. The WaitForSingleObject function makes sure the message is processed. To use this function, you must specify two parameters:

hHandle - the handle of the object you want to monitor.


dwMilliseconds - specifies the time-out interval, in milliseconds. If you set this parameter to INFINITE, the function's time-out interval never elapses.


To make sure that the program is closed, use the IsWindow function to determine if the handle still exists. The IsWindow function determines if the handle is valid. The function returns a non-zero value if the handle is valid and zero if the handle does not exists. To use this function, you just have to specify the handle to check.

If the handle still exists, then you can use the TerminateProcess function to stop the handle process. However, this extreme approach is not recommended because while you may have stopped the handle process, the DLL's used by the handle may still reside in memory, causing a memory leak. Use the TerminateProcess function with caution.

The next section shows how to create a sample program that demonstrates how to close a running application from a Visual Basic program. The program starts and stops the Windows calculator program.

Create the Sample Project
Start a new Standard EXE project in Visual Basic. Form1 is created by default.


Add two CommandButtons to Form1.


Copy the following code to the Code window of the Form1 form:


      Option Explicit

      Private Declare Function WaitForSingleObject Lib "kernel32" _
         (ByVal hHandle As Long, _
         ByVal dwMilliseconds As Long) As Long

      Private Declare Function FindWindow Lib "user32" _
         Alias "FindWindowA" _
         (ByVal lpClassName As String, _
         ByVal lpWindowName As String) As Long

      Private Declare Function PostMessage Lib "user32" _
         Alias "PostMessageA" _
         (ByVal hwnd As Long, _
         ByVal wMsg As Long, _
         ByVal wParam As Long, _
         ByVal lParam As Long) As Long

      Private Declare Function IsWindow Lib "user32" _
         (ByVal hwnd As Long) As Long

      'Constants used by the API functions
      Const WM_CLOSE = &H10
      Const INFINITE = &HFFFFFFFF

      Private Sub Form_Load()
         Command1.Caption = "Start the Calculator"
         Command2.Caption = "Close the Calculator"
      End Sub

      Private Sub Command1_Click()
      'Starts the Windows Calculator
         Shell "calc.exe", vbNormalNoFocus
      End Sub

      Private Sub Command2_Click()
      'Closes the Windows Calculator
         Dim hWindow As Long
         Dim lngResult As Long
         Dim lngReturnValue As Long

         hWindow = FindWindow(vbNullString, "Calculator")
         lngReturnValue = PostMessage(hWindow, WM_CLOSE, vbNull, vbNull)
         lngResult = WaitForSingleObject(hWindow, INFINITE)

         'Does the handle still exist?
         DoEvents
         hWindow = FindWindow(vbNullString, "Calculator")
         If IsWindow(hWindow) = 1 Then
            'The handle still exists. Use the TerminateProcess function
            'to close all related processes to this handle. See the
            'article for more information.
            MsgBox "Handle still exists."
         Else
            'Handle does not exist.
            MsgBox "Program closed."
         End If
      End Sub
Press the F5 key to run the program. Click Start the Calculator to start the Windows calculator program. Click Close the Calculator to close the Windows calculator program.
0
 
LVL 2

Expert Comment

by:ramses
ID: 6435570
These can also be of assistance in finding the handle of Point32:

Howto: get a Window Handle Without Specifying an Exact Title: http://support.microsoft.com/support/kb/articles/Q147/6/59.asp?LN=NL&SD=gn&FR=0

And

How to Get a Window's Class Name and Other Attributes: http://support.microsoft.com/support/kb/articles/Q112/6/49.ASP


Hope this helps


Just scream 4 more :-)

Ramses
0
 
LVL 2

Author Comment

by:taplin
ID: 6436704
YOU ARE THE MAN!!!!!!!!!!!!!!!!!!!!

Did it!  Works great!  No more need to scream!  Thank you so much!

I determined the Window title and passed it in via the code, and everything works great!

Thanks!
0
 
LVL 2

Author Comment

by:taplin
ID: 6436747
Forgot to accept the answer!!!
0
 
LVL 2

Expert Comment

by:ramses
ID: 6436771
You're welcome.



I'll keep Email-Notification for this question ON so, should you have any more questions/comments regarding this topic, just add a comment and I will be notified so that we can look in to that right away



Ramses
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now