उदाहरण के लिए ".myp" फ़ाइल फ़ाइल को पंजीकृत करने का सबसे आसान तरीका है, उदाहरण के लिए ".myp" और जब उपयोगकर्ता साइट पर "myapp प्रारंभ करें" दबाता है तो यह फ़ाइल "startapp.myp" डाउनलोड करता है।
विंडोज फिर फ़ाइल के विस्तार को देखेंगे और यह पता लगाएंगे कि यह आपके ऐप में पंजीकृत है और फ़ाइल के साथ कमांड पैरामीटर के रूप में अपना एप्लिकेशन शुरू करें। तब आपका ऐप फ़ाइल को पढ़ सकता है और सामग्री के आधार पर सामान कर सकता है।
(उदाहरण http://www.developerfusion.com/article/36/file-assocation/2/ से लिया लेकिन यहाँ लगातार कारण के लिए नकल की जाती है टिप्पणी के लिए मूल साइट की जांच)
'// Registry windows api calls
Private Declare Function RegCreateKey& Lib "advapi32.DLL" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpszSubKey As String, ByVal lphKey As Long)
Private Declare Function RegSetValue& Lib "advapi32.DLL" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpszSubKey As String, ByVal fdwType As Long, ByVal lpszValue As String, ByVal dwLength As Long)
'// Required constants
Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const MAX_PATH = 256&
Private Const REG_SZ = 1
'// procedure you call to associate the tmg extension with your program.
Private Sub MakeDefault()
Dim sKeyName As String '// Holds Key Name in registry.
Dim sKeyValue As String '// Holds Key Value in registry.
Dim ret As Long '// Holds error status if any from API calls.
Dim lphKey As Long '// Holds created key handle from RegCreateKey.
'// This creates a Root entry called "TextMagic"
sKeyName = "TextMagic" '// Application Name
sKeyValue = "TextMagic Document" '// File Description
ret = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey)
ret = RegSetValue&(lphKey&, Empty, REG_SZ, sKeyValue, 0&)
'// This creates a Root entry called .tmg associated with "TextMagic".
sKeyName = ".tmg" '// File Extension
sKeyValue = "TextMagic" '// Application Name
ret = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey)
ret = RegSetValue&(lphKey, Empty, REG_SZ, sKeyValue, 0&)
'//This sets the command line for "TextMagic".
sKeyName = "TextMagic" '// Application Name
If Right$(App.Path, 1) = "\" Then
sKeyValue = App.Path & App.EXEName & ".exe %1" '// Application Path
Else
sKeyValue = App.Path & "\" & App.EXEName & ".exe %1" '// Application Path
End If
ret = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey)
ret = RegSetValue&(lphKey, "shell\open\command", REG_SZ, sKeyValue, MAX_PATH)
End Sub
Private Sub Form_Load()
'// ensure we only register once. When debugging etc, remove the SaveSetting line, so your program will
'// always attempt to register the file extension
If GetSetting(App.Title, "Settings", "RegisteredFile", 0) = 0 Then
'// associate tmg extension with this app
MakeDefault()
SaveSetting(App.Title, "Settings", "RegisteredFile", 1)
End If
'// check command line argument:
If Command$ <> Empty Then
'// we have a file to open
'// Fetch the file name from Command$ and then read the file if needed.
End If
End Sub
कौन सा मंच:
यहाँ VB.Net में किया अपने आवेदन करने के लिए एक फ़ाइल प्रकार रजिस्टर करने के लिए कोड कर रहे हैं? वर्तमान के लिए – arul
विंडोज़, लेकिन मेरे पास विचार हैं ... – kmontgom