© From 2013, June 08. Powered by Blogger.
RSS

[Code] Add/Remove Software From StartUp **Code Shared By tnt1**

*****At First Make a Module And Add This Code*****

Option Explicit

Public Const REG_SZ = 1 ' Unicode nul terminated string
Public Const REG_BINARY = 3 ' Free form binary

Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const HKEY_PERFORMANCE_DATA = &H80000004
Public Const HKEY_CURRENT_CONFIG = &H80000005
Public Const HKEY_DYN_DATA = &H80000006

Private Const ERROR_SUCCESS = 0&

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 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
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long

Public Function RegistrySaveString(hKey As Long, strPath As String, strValue As String, strData As String) As String
    Dim h&, r

    'Create a new key, or open the key already existing in that location, and return the handle to into h
    r = RegCreateKey(hKey, strPath, h)
    If r <> ERROR_SUCCESS Then RegistrySaveString = r: Exit Function

    'create a subkey beneath the key just created/opened and store a string in it.
    r = RegSetValueEx(h, strValue, 0, REG_SZ, ByVal strData, Len(strData))
    If r = ERROR_SUCCESS Then RegistrySaveString = "SuckSexFull !! **mJTools.Tk**" Else RegistrySaveString = r

    'close the key
    r = RegCloseKey(h)

End Function

Public Function RegistryDeleteString(hKey As Long, strPath As String, strValue As String) As String
    Dim h&, r
    'Create a new key
    r = RegCreateKey(hKey, strPath, h)
    If r <> ERROR_SUCCESS Then RegistryDeleteString = r: Exit Function

    'Delete the key's value
    r = RegDeleteValue(h, strValue)
    If r = ERROR_SUCCESS Then RegistryDeleteString = "SuckSexFull !! **mJTools.Tk**" Else RegistryDeleteString = r
    'close the key
    RegCloseKey h
End Function

Public Function MakeThisAppRunAtStartup() As String
    MakeThisAppRunAtStartup = RegistrySaveString(HKEY_LOCAL_MACHINE, "SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN", App.EXEName, App.Path & "\" & App.EXEName & ".exe")
End Function

Public Function UnMakeThisAppRunAtStartup() As String
    UnMakeThisAppRunAtStartup = RegistryDeleteString(HKEY_LOCAL_MACHINE, "SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN", App.EXEName)
End Function

*****This Code In Form For Add / Remove*****

Private Sub Removs_Click()
MsgBox UnMakeThisAppRunAtStartup
End Sub

Private Sub Adds_Click()
MsgBox MakeThisAppRunAtStartup
End Sub

************************************************************

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 Comments:

Post a Comment