zoukankan      html  css  js  c++  java
  • 让自己的软件实现双击打开文件(修改注册表设置关联)

    让自己的软件实现双击打开文件
    作者:帅宏军

    unit shjAssociateFileType;
    
    interface
    uses Windows, Registry;
    {将文件类型strFileExtension与程序strExeFileName相关联,strDiscription为文件类型说明}
    function AssignToProgram(const strFileExtension, strDiscription, strExeFileName: string ): boolean;
    
    implementation
    {将文件类型strFileExtension与程序strExeFileName相关联,strDiscription为文件类型说明}
    function AssignToProgram(const strFileExtension, strDiscription, strExeFileName: string ): boolean;
    var
      regFile: TRegistry;
    begin
      //建立一个Registry实例
      regFile := TRegistry.Create;
      with regFile do
      begin
        //设置根键值为HKEY_CLASSES_ROOT
        RootKey := HKEY_CLASSES_ROOT;
        //创建或者打开扩展名自动关联注册键
        OpenKey( '.' + strFileExtension, true);
        //设置扩展名自动关联
        WriteString('', strFileExtension + '_Auto_File');
        //关闭键
        CloseKey;
        //创建或者打开打开自动关联键
        OpenKey(strFileExtension + '_Auto_File', true);
        //设置文件类型说明
        WriteString('', strDiscription);
        //关闭键
        CloseKey;
        //创建或打开关联程序键
        OpenKey(strFileExtension + '_Auto_Fileshellopencommand', true);
        //设置关联程序(注意:%1加上双引号,可以解决文件路径中含空格的问题)
        WriteString('',strExeFileName + ' "%1"');
        //关闭键
        CloseKey;
        //打开默认图标键
        OpenKey(strFileExtension + '_Auto_Filedefaulticon',true);
        //关联默认图标
        WriteString('', strExeFileName + ',0');
        //释放
        Free;
        Result := True;
      end;
    end;
    end.

    http://blog.csdn.net/shuaihj/article/details/7046515

  • 相关阅读:
    SqlBulkCopy类进行大数据(10000万条以上)插入测试
    win7 64位下android开发环境的搭建
    Linq语法详细
    理解ASP.NET MVC中的ActionResult
    webBrowser 模拟登录
    C#中的WebBrowser控件的使用
    httpwebrequest详解【转】
    Post方式调用wcf服务
    EXTJS4.2 控件之Grid getRowClass 添加行背景色
    SQL 跨服务器数据库增、删、改、查(二)
  • 原文地址:https://www.cnblogs.com/findumars/p/5345733.html
Copyright © 2011-2022 走看看