'This Code Source is:
'http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=1&txtCodeId=35734&txtForceRefresh=111820052319056771

'**************************************
'Windows API/Global Declarations for :Ad
'     d your program to the Right-Mouse-Click 
'     menu
'**************************************
Const REG_SZ = 1
Const HKEY_LOCAL_MACHINE = &H80000002


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

'**************************************
' Name: Add your program to the Right-Mo
'     use-Click menu
' Description:Let your program be listed
'     in the right-mouse-click for a particula
'     r file type. You program can then be run


'     with a simple click
' By: Jamin
'
' Inputs:The filetype you want to add to
'     . Your program's path & filename.
'
' Returns:Adds a registry key
'
' Assumes:This program only adds the reg
'     isrty key. It can be removed by running 
'     regedit then manually deleting the key. 
'     The location can be seen in the code.
'
' Side Effects:Playing with the registry
'     can be dangerous. I have run this on my 
'     computer and it works fine. I take no re
'     sponsibility for any mishaps that occur.
'     
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=35734&lngWId=1
'for details.'**************************************



Public Sub SetStringValue(Hkey As Long, strPath As String, strValue As String, strdata As String)
    Dim keyhand As Long
    Dim i As Long
    i = RegCreateKey(Hkey, strPath, keyhand)
    'Changed the normal keyvalue name to vbN
    '     ullString to set it as the (Default) val
    '     ue
    i = RegSetValueEx(keyhand, vbNullString, 0, REG_SZ, ByVal strdata, Len(strdata))
    i = RegCloseKey(keyhand)
End Sub


Private Sub Form_Load()
    'Create Reg Key for filetype, (can be fo
    '     und by looking in HKEY_CLASSES_ROOT then
    '     the extension, the (Default) value piont
    '     s to the file type, located in the HKEY_
    '     CLASSES_ROOT folder)
    'Replace """C:\Project1.exe"" %1" with y
    '     our program path & name. "%1" means send
    '     the file name you click on as the comman
    '     dline arguments.
    SetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Classes\Paint.Picture\shell\Text To Display\command", 0, """C:\Project1.exe"" %1"
End Sub
