Results 1 to 8 of 8

Thread: At least 2 icons

  1. #1

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    How do i put 2 or more icons in my compiled exe?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    You can add Icons to a RESOURCE file which gets compiled into your EXE the First Icon resource then replaces your EXE icon and the others are accessable via an Index.

  3. #3

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Thanks, do you know how to update the filetypes too? That would help me much
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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

    Sure...

    Sure,

    Use the SHChangeNotify() API with the SHCNE_ASSOCCHANGED Constant, i.e.

    In a Module:
    Code:
    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 RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    Private Declare Function SHChangeNotify Lib "shell32.dll" (ByVal wEventID As Long, ByVal uFlags As Long, ByVal dwItem1 As String, ByVal dwItem2 As String) As Long
    
    Private Const HKEY_CLASSES_ROOT = &H80000000
    Private Const SHCNE_ASSOCCHANGED = &H8000000
    Private Const SHCNF_IDLIST = &H0
    
    Public Sub AssociateMyApp(ByVal sAppName As String, ByVal sEXE As String, ByVal sExt As String, Optional ByVal sIcon As String)
        Dim lRegKey As Long
        'Open/Create the Extension under the "HKEY_CLASSES_ROOT" Hive of the Registry
        Call RegCreateKey(HKEY_CLASSES_ROOT, sExt, lRegKey)
        'Set the "Default" value of the Key to the Application Name
        Call RegSetValueEx(lRegKey, "", 0&, 1, ByVal sAppName, Len(sAppName))
        'Close the Registry Key
        Call RegCloseKey(lRegKey)
        'Create the Application Key in the "HKEY_CLASSES_ROOT" Hive of the Registry
        Call RegCreateKey(HKEY_CLASSES_ROOT, sAppName & "\Shell\Open\Command", lRegKey)
        'Set the Command to the EXE
        Call RegSetValueEx(lRegKey, "", 0&, 1, ByVal sEXE, Len(sEXE))
        'Close the Registry Key
        Call RegCloseKey(lRegKey)
        'If an Icon is required...
        If Len(sIcon) Then
           'Create a "DefaultIcon" entry under the Association Key
            Call RegCreateKey(HKEY_CLASSES_ROOT, sAppName & "\DefaultIcon", lRegKey)
            Call RegSetValueEx(lRegKey, "", 0&, 1, ByVal sIcon, Len(sIcon))
            Call RegCloseKey(lRegKey)
        End If
        'Notify the Shell that an Association has Changed, (Updates Icons).
        SHChangeNotify SHCNE_ASSOCCHANGED, SHCNF_IDLIST, vbNullString, vbNullString
    End Sub
    Example Usage:
    Code:
    AssociateMyApp "Kedamans Application", "C:\Files\Kedaman.exe %1", ".kdm", "C:\Files\Kedaman.exe,-1"
    - Aaron.

  5. #5

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Thumbs up

    Thanks alot, i needed that shchangenotify part
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Question

    Another Q, how can i drag a file on another, which should start my app? Winzip does it, so it's not impossible!
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    If you drag a file onto an Executable then it'll start the Executable and pass the Dropped files filename and path as a Command Line, so you can us it in your application using the "Command" keyword.

  8. #8

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    No no, I have done that already but how do i drag one file on another (not executable) like winzip, you can drag a file on a zip extension. There's a shellex key in the registry and i tried to copy it to my datatype but it didn't work...
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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