n,“请注意” End If OSRegCloseKey
(hKey) End
Sub 6、按F5运行程序,在简体中文Windows95/NT/98、VB5.0/6.0环境中调试通过。 ㈡利用Delphi编程 1、在Delphi3.0
IDE中,新建工程Project1,在Form1上添加按钮Button1。 2、在uses子句中添加Registry。 3、双击Button1,编写Click事件代码。 procedure
TForm1.Button1Click(Sender: Tobject); var MyRegistry :
TRegINIFile; Return:string; begin try MyRegistry :=
TRegINIFile.Create(``); MyRegistry.RootKey := HKEY_CLASSES_ROOT;
Return:=MyRegistry.ReadString (`.gid`,``,`No! Not Found the Key!`);
MyRegistry.WriteString(Return,``,`这只是一个演示!`);
MyRegistry.WriteString(Return+`\DefaultIcon`,``,`c:\visio.exe,1`);
MyRegistry.WriteString(Return+`\shell\open\command`,``,`c:\visio.exe %1`);
finally MyRegistry.Free; end;
ShowMessage(`改变文件打开方式成功!`); end; 4、按F9运行程序,在简体中文Windows95/NT/98、Delphi3.0/4.0环境中调试通过。