Check out http://www.codeoftheweek.com/powerfindpro for a great time-saving add-in for Visual Basic.
This issue was designed for VB 4.0 32-bit and up. Questions? Email us at email@example.com.
The complete source code appears near the end of this issue. Be sure not to miss it!
This issue is an enhancement to issue number 64. This issue enhances the cRegistryUtils class by adding the ability to get and retrieve information about the items that Windows will startup upon login.
The property added to cRegistryUtils is called Run. All the rest of the functions included in the cRegistryUtils class are documented in Issue #24 - http://www.codeoftheweek.com/issues/0024.html or #64 - http://www.codeoftheweek.com/issues/0064.html
Windows stores some information in the registry that it uses to determine which applications to start upon login to Windows. This behaves much like putting an application in the Startup folder. This biggest difference is that it is harder for the end user to remove an item from the registry than the Startup folder.
This class works by adding an additional key to the HKLM\Software\Microsoft\Windows\CurrentVersion\Run folder in the registry. There is another key in the registry called RunOnce that behaves just like the Run except that the application will only be started on the next invocation of Windows or re-login to Windows. Once the application starts the key will be removed from the RunOnce folder and never started again. This is useful for installation programs and other situations where you need to update something in Windows only once. You can add a RunOnce property to this class to implement this feature if you need it.
There is one new property called Run.
Public Property Get Run(sAppName As String) As String Public Property Let Run(sAppName As String, sCommandLine As String)
Returns an error if the retrieval or assignment of the application was not succesful. Otherwise the Run property will return the command line of the key specified by sAppName.
Below is an example of how this function works.
Dim Reg As New cRegistryUtils Debug.Print Reg.Run("DU Meter") ' on my system this prints out: C:\PROGRAM FILES\DU METER\DUMETER.EXE Reg.Run("TestKey") = "c:\windows\notepad.exe" Debug.Print Reg.Run("TestKey") ' this will print out c:\windows\notepad.exe
To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address: http://www.codeoftheweek.com/membersonly/bi/0085.html