Create a file association for your application (Works in Windows 95/98/NT/2000/ME)
Create a file association so files with a give extension will be automatically opened by your application
AI
KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Quellcode
Public Sub CreateAssociation(sExtension as String, sApplication as String, sAppPath as String)
Dim sPath As String
CreateNewKey "." & sExtension, HKEY_CLASSES_ROOT
SetKeyValue "." & sExtension, "", sApplication & ".Document", REG_SZ
CreateNewKey sApplication & ".Document\shell\open\command", HKEY_CLASSES_ROOT
SetKeyValue sApplication & ".Document", "", sApplication & " Document", REG_SZ
sPath = sAppPath & " %1"
SetKeyValue sApplication & ".Document\shell\open\command", "", sPath, REG_SZ
CreateNewKey "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\." _
& sExtension, HKEY_CURRENT_USER
SetKeyValue2 "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\." _
& sExtension, "Application", sAppExe, REG_SZ
CreateNewKey "Applications\" & sAppExe & "\shell\open\command", HKEY_CLASSES_ROOT
SetKeyValue "Applications\" & sAppExe & "\shell\open\command", "", sPath, REG_SZ
End Sub
Public Function SetValueEx(ByVal hKey As Long, _
sValueName As String, _
lType As Long, _
vValue As Variant) As Long
Dim nValue As Long
Dim sValue As String
Select Case lType
Case REG_SZ
sValue = vValue & Chr$(0)
SetValueEx = RegSetValueExString(hKey, _
sValueName, _
0&, _
lType, _
sValue, _
Len(sValue))
Case REG_DWORD
nValue = vValue
SetValueEx = RegSetValueExLong(hKey, _
sValueName, _
0&, _
lType, _
nValue, _
4)
End Select
End Function
Public Sub CreateNewKey(sNewKeyName As String, _
lPredefinedKey As Long)
Dim hKey As Long
Dim result As Long
Call RegCreateKeyEx(lPredefinedKey, _
sNewKeyName, 0&, _
vbNullString, _
REG_OPTION_NON_VOLATILE, _
KEY_ALL_ACCESS, 0&, hKey, result)
Call RegCloseKey(hKey)
End Sub
Public Sub SetKeyValue(sKeyName As String, _
sValueName As String, _
vValueSetting As Variant, _
lValueType As Long)
Dim hKey As Long
Call RegOpenKeyEx(HKEY_CLASSES_ROOT, _
sKeyName, 0, _
KEY_ALL_ACCESS, hKey)
Call SetValueEx(hKey, _
sValueName, _
lValueType, _
vValueSetting)
Call RegCloseKey(hKey)
End Sub
Public Sub SetKeyValue(sKeyName As String, _
sValueName As String, _
vValueSetting As Variant, _
lValueType As Long)
Dim hKey As Long
Call RegOpenKeyEx(HKEY_CURRENT_USER, _
sKeyName, 0, _
KEY_ALL_ACCESS, hKey)
Call SetValueEx(hKey, _
sValueName, _
lValueType, _
vValueSetting)
Call RegCloseKey(hKey)
End Sub
Originalkommentare (3)
Wiederhergestellt von der Wayback Machine