Results 1 to 3 of 3

Thread: Can Some One Help ME On THis PLease!!!!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Posts
    219

    Post

    how can i have my program open program and right to it and tell it to open up my program?? or how can i tell the registry that? Please Help Me

    Thanx,
    Evil

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Can you be more specific. Why would you want to open a program then open another program and tell that program to open your program again? Maybe I missunderstood someting. Please, rephrase the question.


    Regards,

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

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Do you mean.. How do I Associate an Extension with my Application?..
    Like when you double Click a File ending with .txt it launches it in Notepad?

    If so, then here's an example which Asscociates the file Extension .abc with Notepad..
    Code:
    Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As Any, phkResult As Long, lpdwDisposition 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 RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    
    Private Const HKEY_CLASSES_ROOT = &H80000000
    Private Const REG_CREATED_NEW_KEY = &H1
    Private Const REG_OPENED_EXISTING_KEY = &H2
    Private Const REG_SZ = 1
    
    Private Const STANDARD_RIGHTS_ALL = &H1F0000
    Private Const KEY_QUERY_VALUE = &H1
    Private Const KEY_SET_VALUE = &H2
    Private Const KEY_CREATE_SUB_KEY = &H4
    Private Const KEY_ENUMERATE_SUB_KEYS = &H8
    Private Const KEY_NOTIFY = &H10
    Private Const KEY_CREATE_LINK = &H20
    Private Const SYNCHRONIZE = &H100000
    
    Private Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
    
    Private Sub Command1_Click()
        Dim lRegKey As Long
        Dim lResult As Long
        Const sApp = "Notepad.exe %1" 'App to Run
        Const sExt = ".abc"           'Extension to Associate
        Const sExtDesc = "ABC File"   'Descriptive Name of Extension
        
        Call RegCreateKeyEx(HKEY_CLASSES_ROOT, sExt & "\", 0&, "", 0&, KEY_ALL_ACCESS, ByVal 0&, lRegKey, lResult)
        If lResult = REG_CREATED_NEW_KEY Or lResult = REG_OPENED_EXISTING_KEY Then
            'Reg Opened/Created Successfully..
            lResult = RegSetValueEx(lRegKey, "", 0&, REG_SZ, ByVal sExtDesc, Len(sExtDesc))
            Call RegCloseKey(lRegKey)
            If lResult = 0 Then
                'Value set successfully..
                Call RegCreateKeyEx(HKEY_CLASSES_ROOT, sExtDesc & "\Shell\Open\Command\", 0&, "", 0&, KEY_ALL_ACCESS, ByVal 0&, lRegKey, lResult)
                If lResult = REG_CREATED_NEW_KEY Or lResult = REG_OPENED_EXISTING_KEY Then
                    'Reg Opened/Created Successfully..
                    lResult = RegSetValueEx(lRegKey, "", 0&, REG_SZ, ByVal sApp, Len(sApp))
                    If lResult = 0 Then
                        MsgBox "Extension Associated"
                    Else
                        MsgBox "Failed to Associate Extension"
                    End If
                End If
            End If
        End If
        Call RegCloseKey(lRegKey)
        
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width