-
Hi
I have made a Notepad like prog, what I need is
to let my prog open txt files instead of Microsoft's
Notepad.
Ex. When I doubleClick a TXT file I want my prog to start
and open the TXT file.
Is this possible with VB?
Hope you can help
Thanks
Chris
-
Hey mate
A week or two ago the same question was asked for some other type of file, so just search throught the general forums and u should find it
good luck!!
-
-
I believe the following would help, but I haven¡¯t tried it. The general idea is to make an attempt to modify the Registry (It is vital to make a backup copy of the Registry before you make any modification of it).
1. Change the subkey ¡°HKEY_CLASSES_ROOT\txtfile\DefaultIcon¡± default value to the path and name of your own icon file;
2. Change the subkey ¡°HKEY_CLASSES_ROOT\txtfile\shell\open\command¡± default value to the path and name of your own program file with which any text file is, by double clicking, automatically opened.
---------------------------------
You can try to do it manually first and then in code.
BUT
Remember to make a backup copy of the Registry! Any mistakes in attempting it would perhaps be fatal to the system.
---------------------------------
The following Win32 API functions may help you accomplish that. For details see VB Help.
Steps:
---------------------------------
---- Open the main key and subkey;
---- Set the value;
---- Close the keys.
---------------------------------
Win32 API functions:
---------------------------------
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey 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 RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
---------------------------------
Visual Basic Professional 6.0
-