Make a File Association Los Angeles CA

Many programs these days come with their own file format, so why shouldn't yours? By accessing the correct parts of the registry you can make a link to your own file type, and execute your program when the file is double clicked on.

Local Companies

Moyea Software
92295612365
Hot building, ring street
LA, CA
Interneer Inc.
8005586832 x85
6101 W. Centinela Ave.
Culver City, CA
Cornerstone Concepts Inc
818-247-3909
600 W Broadway
Glendale, CA
Greene Computer Corporation
(818) 956-4961
200 S. Louise Street
Glendale, CA
Corticalx Inc Software Solutions & Technology
818-500-0881
425 E Colorado St
Glendale, CA
Alphatier Systems
818-409-8920
517 Griswold St
Glendale, CA
TimeTECH - Customizable Time and Attendance / Workforce Management Solutions
905-677-7009
7420 Airport Rd 203
Mississauga, CA
Hutchinson & Bloodgood, LLP
(818) 637-5000
101 N. Brand Blvd. #1600
Glendale, CA
Telsoft Solutions
818-545-8680
100 N Brand Blvd
Glendale, CA
Abraxas Technologies Inc
818-502-9100
450 N Brand Blvd
Glendale, CA

provided by: 
Originally published at Internet.com


Many programs these days come with their own file format, so why shouldn't yours? By accessing the correct parts of the registry you can make a link to your own file type, and execute your program when the file is double clicked on. This topic is far from complete in that you would want to interpret the command line parameters sent to your program about the file. This sample code creates a link to .xxx files and calls them MyApp.Document. It then loads up c:\LongPathname\MyApp.Exe Change these values as appropiate.

Add a new form with a command button (cmdTest). Copy the following code into the form: Option Explicit '// Windows Registry Messages Private Const REG_SZ As Long = 1 Private Const REG_DWORD As Long = 4 Private Const HKEY_CLASSES_ROOT = &H80000000 Private Const HKEY_CURRENT_USER = &H80000001 Private Const HKEY_LOCAL_MACHINE = &H80000002 Private Const HKEY_USERS = &H80000003 '// Windows Error Messages Private Const ERROR_NONE = 0 Private Const ERROR_BADDB = 1 Private Const ERROR_BADKEY = 2 Private Const ERROR_CANTOPEN = 3 Private Const ERROR_CANTREAD = 4 Private Const ERROR_CANTWRITE = 5 Private Const ERROR_OUTOFMEMORY = 6 Private Const ERROR_INVALID_PARAMETER = 7 Private Const ERROR_ACCESS_DENIED = 8 Private Const ERROR_INVALID_PARAMETERS = 87 Private Const ERROR_NO_MORE_ITEMS = 259 '// Windows Security Messages Private Const KEY_ALL_ACCESS = &H3F Private Const REG_OPTION_NON_VOLATILE = 0 '// Windows Registry API calls Private Declare Function RegCloseKey Lib "advapi32.dll" _ (ByVal hKey As Long) As Long Private Declare Function RegCreateKeyEx _ Lib "advapi32.dll" Alias "RegCreateKeyExA" _ (ByVal hKey As Long, _ ByVal lpSubKey As String, _ ByVal Reserved As Long, _ ByVal lpClass As String, _ ByVal dwOptions As Long, _ ByVal samDesired As Long, _ ByVal lpSecurityAttributes As Long, _ phkResult As Long, _ lpdwDisposition As Long) 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 RegSetValueExString _ Lib "advapi32.dll" Alias "RegSetValueExA" _ (ByVal hKey As Long, _ ByVal lpValueName As String, _ ByVal Reserved As Long, _ ByVal dwType As Long, _ ByVal lpValue As String, _ ByVal cbData As Long) As Long Private Declare Function RegSetValueExLong _ Lib "advapi32.dll" Alias "RegSetValueExA" _ (ByVal hKey As Long, _ ByVal lpValueName As String, _ ByVal Reserved As Long, _ ByVal dwType As Long, _ lpValue As Long, _ ByVal cbData As Long) As Long Private Sub CreateAssociation() Dim sPath As String '// File Associations begin with a listing '// of the default extension under HKEY_CLASSES_ROOT. '// So the first step is to create that '// root extension item CreateNewKey ".xxx", HKEY_CLASSES_ROOT '// To the extension just added, add a '// subitem where the registry will look for '// commands relating to the .xxx extension '// ("MyApp.Document"). Its type is String (REG_SZ) SetKeyValue ".xxx", "", "MyApp.Document", REG_SZ '// Create the 'MyApp.Document' item under '// HKEY_CLASSES_ROOT. This is where you'll put '// the command line to execute or other shell '// statements necessary. CreateNewKey "MyApp.Document\shell\open\command", HKEY_CLASSES_ROOT '// Set its default item to "MyApp Document". '// This is what is displayed in Explorer against '// for files with a xxx extension. Its type is '// String (REG_SZ) SetKeyValue "MyApp.Document", "", "MyApp Document", REG_SZ '// Finally, addd the path to myapp.exe '// Remember to add %1 as the final command '// parameter to assure the app opens the passed '// command line item. '// (results in '"c:\LongPathname\Myapp.exe %1") '// Again, its type is string. sPath = "c:\LongPathname\Myapp.exe %1" SetKeyValue "MyApp.Document\shell\open\command", "", sPath, REG_SZ '// All done MsgBox "The file association has been made!" End Sub Private 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 Private Sub CreateNewKey(sNewKeyName As String, _ lPredefinedKey As Long) '// handle to the new key Dim hKey As Long '// result of the RegCreateKeyEx function Dim r As Long r = RegCreateKeyEx(lPredefinedKey, sNewKeyName, 0&, _ vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hKey, r) Call RegCloseKey(hKey) End Sub Private Sub SetKeyValue(sKeyName As String, sValueName As String, _ vValueSetting As Variant, lValueType As Long) '// result of the SetValueEx function Dim r As Long '// handle of opened key Dim hKey As Long '// open the specified key r = RegOpenKeyEx(HKEY_CLASSES_ROOT, sKeyName, 0, _ KEY_ALL_ACCESS, hKey) r = SetValueEx(hKey, sValueName, lValueType, vValueSetting) Call RegCloseKey(hKey) End Sub Private Sub cmdTest_Click() CreateAssociation End Sub

Author: Sam Huggill

Read article at Internet.com site

Featured Local Company

Moyea Software

92295612365
Hot building, ring street
LA, CA

Related Local Events
Automation Technology Expo West (ATX West)
Dates: 2/9/2010 - 2/11/2010
Location: Anaheim Convention Center
Anaheim, CA
View Details

SOLAR POWER - Exhibition and Conference
Dates: 10/12/2010 - 10/14/2010
Location: Los Angeles Convention & Exhibition Center
Los Angeles, CA
View Details

REAL-TIME & EMBEDDED COMPUTING CONFERENCE - LONG BEACH 2009
Dates: 10/1/2009 - 10/1/2009
Location: Marriott Long Beach
Long Beach, CA
View Details

2009 IEEE Petroleum and Chemical Industry Technical Conference (PCIC 2009)
Dates: 9/14/2009 - 9/16/2009
Location:
Anaheim, CA
View Details

Medical Design & Manufacturing - Trade
Dates: 6/9/2009 - 6/11/2009
Location: CANON COMMUNICATIONS LLC
Los Angeles, CA
View Details