VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Add and Remove your program to the Add/Remove Programs and Run at Startup lists (SMALL CLASS FILE)

Rabid Nerd Productions  (4 Submissions)   Windows API Call/Explanation   Visual Basic 3.0   Beginner   Wed 3rd February 2021

Allows you to easily add your program to the Add/Remove programs list, and also add your program to the Run registry key so it starts every time Windows starts!
I didn't see code that adds to the Add/Remove Programs bit here, so I made it myself! Though I find the basic registry routines here, I did Enum one of the arguments to make calling them faster!
Please Vote!

Inputs
ProgramName and EXE file Paths are needed to set the Uninstall File or File to run at startup

Assumes
You need to have a Dim VarAddRemove as New AddRemove in the Declarations area, and a Set VarAddRemove = New AddRemove in the Form_Load event or Sub Main()

Returns
Returns Nothing.

Side Effects
Dangerous to mess with registry keys!

API Declarations
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal Hkey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Const ERROR_SUCCESS = 0&
Const REG_SZ = 1 ' Unicode nul terminated String
Const REG_DWORD = 4 ' 32-bit number
Public Enum HKeyTypes
HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_USER = &H80000001
HKEY_LOCAL_MACHINE = &H80000002
HKEY_USERS = &H80000003
HKEY_PERFORMANCE_DATA = &H80000004
End Enum

Rate Add and Remove your program to the Add/Remove Programs and Run at Startup lists (SMALL CLASS FILE) (21(21 Vote))
Add and Remove your program to the Add/Remove Programs and Run at Startup lists (SMALL CLASS FILE).bas

Add and Remove your program to the Add/Remove Programs and Run at Startup lists (SMALL CLASS FILE) Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters