How do i put 2 or more icons in my compiled exe?
Printable View
How do i put 2 or more icons in my compiled exe?
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.
Thanks, do you know how to update the filetypes too? That would help me much
Sure,
Use the SHChangeNotify() API with the SHCNE_ASSOCCHANGED Constant, i.e.
In a Module:Example Usage: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
- Aaron.Code:AssociateMyApp "Kedamans Application", "C:\Files\Kedaman.exe %1", ".kdm", "C:\Files\Kedaman.exe,-1"
Thanks alot, i needed that shchangenotify part :)
Another Q, how can i drag a file on another, which should start my app? Winzip does it, so it's not impossible!
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.
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...