文件关联

折腾了一个下午,终于实现了我想要的客户端文件关联的功能,与大家分享一下:)

<%@ page language="java"  import="java.util.*"  pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head >
   <script type="text/javascript">
  
   function f(){
   path="C://Windows//System32//notepad.exe %1"
   //alert(path);
   try{
     ///  al=document.applets[0];
     ///  a1.setCLSID("{F935DC22-1CF0-11D0-ADB9-00C04FD58A0B}");
     ///  a1.createInstance();
      /// shili= a1.GetObject();
      var shili = document.getElementById("tt");
       alert(shili);
      try{
        shili.regwrite("HKCR//.daa//","daa—auto—file");
        shili.regwrite("HKCR//Applications//notepad.EXE//shell//","open");
  shili.regwrite("HKCR//Applications//notepad.EXE//shell//open//","");
  shili.regwrite("HKCR//Applications//notepad.EXE//shell//open//command//",path);
  shili.regwrite("HKCR//daa—auto—file//shell//","open");
  shili.regwrite("HKCR//daa—auto—file//shell//open//","");
  shili.regwrite("HKCR//daa—auto—file//shell//open//command//",path);
  }
  catch(e){
  
  }
  }
  catch(e){}
  
   }
   </script>
   <OBJECT ID="tt" CLASSID="clsid:F935DC22-1CF0-11D0-ADB9-00C04FD58A0B">
  </OBJECT>
  </head>
 
  <body >
  <a href="#" onclick="f()">关联</a>
  <a href="file:///E:/test.daa" >OK</a>
  </body>
</html>

你可能感兴趣的:(文件关联)