Hallo
Du willst wahrscheinlich, das ein gewisser Dateityp mit automatisch mit deinem Programm geladen wird. Ich habe dasselbe mal in VB gefunden und es hat dort auch einwandfrei funktioniert. Du musst es dir halt selbst nach C++ portieren:
Option Explicit
' Benötigte API-Deklarationen
Private Declare Function CharLower Lib "user32" \_
Alias "CharLowerA" ( \_
ByVal lpsz As String) As String
Private Declare Function RegOpenKey Lib "advapi32.dll" \_
Alias "RegOpenKeyA" ( \_
ByVal hKey As Long, \_
ByVal lpSubKey As String, \_
phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" \_
Alias "RegQueryValueExA" ( \_
ByVal hKey As Long, \_
ByVal lpValueName As String, \_
ByVal lpReserved As Long, \_
lpType As Long, \_
lpData As Any, \_
lpcbData 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 RegCreateKey Lib "advapi32.dll" \_
Alias "RegCreateKeyA" ( \_
ByVal hKey As Long, \_
ByVal lpSubKey As String, \_
phkResult As Long) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" \_
Alias "RegDeleteValueA" ( \_
ByVal hKey As Long, \_
ByVal lpValueName As String) As Long
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" \_
Alias "RegOpenKeyExA" ( \_
ByVal hKey As Long, \_
ByVal lpSubKey As String, \_
ByVal ulOptions As Long, \_
ByVal samDesired As Long, \_
phkResult As Long) As Long
Private Declare Function RegEnumKey Lib "advapi32.dll" \_
Alias "RegEnumKeyA" ( \_
ByVal hKey As Long, \_
ByVal dwIndex As Long, \_
ByVal lpName As String, \_
ByVal cbName As Long) As Long
Const KEY\_ENUMERATE\_SUB\_KEYS = &H8
Const ERROR\_SUCCESS = 0&
Const HKEY\_CLASSES\_ROOT = &H80000000
Const REG\_SZ = 1
Private Sub regSaveString(hKey As Long, sPath As String, sValue As String, \_
iData As String)
Dim vRet As Variant
RegCreateKey hKey, sPath, vRet
RegSetValueEx vRet, sValue, 0, REG\_SZ, ByVal iData, Len(iData)
RegCloseKey vRet
End Sub
Public Sub RegisterFileType(ByVal FileType As String)
Dim TypeName As String
If FileType = "" Then
MsgBox "Dateiendung benötigt.", vbCritical
Exit Sub
End If
FileType = CharLower(FileType)
If Left(FileType, 1) "." Then
TypeName = FileType
FileType = "." & FileType
Else
TypeName = Right(FileType, Len(FileType) - 1)
End If
TypeName = TypeName & "file"
regSaveString HKEY\_CLASSES\_ROOT, FileType, "", TypeName
regSaveString HKEY\_CLASSES\_ROOT, TypeName & "\shell\open\command", \_
"", App.Path & "\" & App.Title & ".exe %1"
regSaveString HKEY\_CLASSES\_ROOT, TypeName & "\DefaultIcon", \_
"", App.Path & "\" & App.Title & ".exe,0"
End Sub