Re: Registry entries
- Posted by Falkon <Falkn13 at IBM.NET> Jun 14, 1998
- 578 views
From: Robert B Pilkington >How would you create and modify registry entries in Windows 95 and >Windows NT with Euphoria? There's lotsa ways to do it. For what you want to do, I'd suggest making the file associations yourself via Windows Explorer, rather than having a program do it. If ya don't know how, hit F1 while in Windows Explorer for Windows help and look up the topic 'file associations', and 'create a new file type'. If you really want to mess with the registry directly, I can e-mail you the procedure to enter the keys manually in Regedit, but that's long and complicated to write so I won't take up space here. You can make an INF file that does it, but I don't really know how those work. Search your hard drive for *.inf and look at some in Notepad to try to figure that method out. You could use the Windows API dll calls to do it programmatically, but why bother? Easier still, make a REG file, a plain text file with one key per line, something like this: ------------------------------------- REGEDIT ---command line to edit files of the filetype HKEY_CLASSES_ROOT\efile\shell\edit\command = C:\EUPHORIA\BIN\ex.exe ed.ex %1 HKEY_CLASSES_ROOT\ewfile\shell\edit\command = C:\EUPHORIA\BIN\ex.exe ed.ex %1 HKEY_CLASSES_ROOT\exfile\shell\edit\command = C:\EUPHORIA\BIN\ex.exe ed.ex %1 HKEY_CLASSES_ROOT\exwfile\shell\edit\command = C:\EUPHORIA\BIN\ex.exe ed.ex %1 ---command line to run files of the filetype HKEY_CLASSES_ROOT\exfile\shell\open\command = C:\EUPHORIA\BIN\ex.exe %1 HKEY_CLASSES_ROOT\exwfile\shell\open\command = C:\EUPHORIA\BIN\exw.exe %1 ---icons HKEY_CLASSES_ROOT\efile\DefaultIcon = C:\EUPHORIA\BIN\e.ico,0 HKEY_CLASSES_ROOT\ewfile\DefaultIcon = C:\EUPHORIA\BIN\ew.ico,0 HKEY_CLASSES_ROOT\exfile\DefaultIcon = C:\EUPHORIA\BIN\ex.ico,0 HKEY_CLASSES_ROOT\exwfile\DefaultIcon = C:\EUPHORIA\BIN\exw.ico,0 --- File extension must have filetype as its value HKEY_CLASSES_ROOT\.e = efile HKEY_CLASSES_ROOT\.ew = ewfile HKEY_CLASSES_ROOT\.ex = exfile HKEY_CLASSES_ROOT\.exw = exwfile ------------------------------ Edit the paths and command lines so that they're accurate for your directory structure and the editor you want to use, and change the icon paths/names to whatever they are on your system. You can also create other shell commands for the filetypes if you want Print, New, or other commands on the menu. Before you merge it, make sure that the first line is nothing but the word REGEDIT, and every line with a key value starts at the very beginning. (No spaces before the word HKEY_...) Also make sure you don't have any of the keys or values wordwrapped. A key and its value must be on the same line. You should also make a backup of your registry just in case. Once you've got the REG file the way you want it, save it, right click on it and choose Merge, or pass it to Regedit as a command-line parameter. Look at some of the REG files on your hard drive for examples. Note that a newer version of Regedit uses text files that look more like: REGEDIT4 [HKEY_CLASSES_ROOT\exfile\shell\open\command] @="C:\EUPHORIA\BIN\ex.exe %1" These work the same way, but I think you should use the other style for compatibility with other versions of Regedit. You could of course write a program to generate the reg file based upon the user's directory structure and choice of editors, etc, and then merge it via system(). Just remember to always make a backup before experimenting on the registry. In Win95, it's two files, SYSTEM.DAT and USER.DAT in the Windows directory. That's the only one I have experience with, the following info I got from a text file on www.wotsit.org: In Windows 3.1 there's only one file named REG.DAT. In Windows NT there's a whole bunch of files, SYSTEM32\CONFIG\SAM SYSTEM32\CONFIG\SOFTWARE SYSTEM32\CONFIG\SYSTEM PROFILES\%USERNAME%\NTUSER.DAT PROFILES\%USERNAME%\NTUSER.MAN and Regedit is called Regedt32