Delphi 让自己的软件实现双击打开文件 转

时间:2023-02-25 10:56:53

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_File\shell\open\command', true);

//设置关联程序(注意:%1加上双引号,可以解决文件路径中含空格的问题)
    WriteString('',strExeFileName + ' "%1"');

//关闭键
    CloseKey;

//打开默认图标键
    OpenKey(strFileExtension + '_Auto_File\defaulticon',true);

//关联默认图标
    WriteString('', strExeFileName + ',0');

//释放
    Free;

Result := True;
  end;
end;

end.

Delphi 让自己的软件实现双击打开文件 转的更多相关文章

  1. xmind 8 便携版:关联文件后,双击打开文件,在当前文件夹产生configuration子文件的问题解决办法

    Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\.xmind] @="XMind.Workbook.3" &quot ...

  2. vs2013修改为双击打开文件

    vs2012和vs2013默认是单击打开文件,让人突然就不习惯了,各种不爽. 修改方法: 工具-选项-环境-选项卡和窗口-不勾选允许在预览选项卡中打开新文件.

  3. Idea 设置单击打开文件或者双击打开文件、自动定位文件所在的位置

    以下定位,框架下,打开文件的点击方式,以及点击标签导航页上的已打开文件定位到展开路径,如下图:

  4. IntelliJ Idea设置单击打开文件或者双击打开文件、自动定位文件所在的位置

  5. 【温故Delphi】双击工程文件打开软件

    问题描述 大部分软件都有鼠标双击文件,就能打开所关联的软件并打开所选工程,这是如何做到的呢? 把文件关联到一个程序中,双击文件来启动程序,那么这个文件名称就是这个程序的命令行的一个参数. 所以要想实现 ...

  6. Delphi 实现最近打开文件记录菜单

    unit UntOpenMenu; //download by http://wwww.NewXing.com interface uses Windows, Messages, SysUtils, ...

  7. excel文件双击打开空白

    excel文件双击打开之后进入软件,没有去读文件 一.现象描述 打开现象如下所示,只有excel模板,看不到excel中的表格模板. 二.想要打开文件 (1)在软件的文件--->打开--> ...

  8. 20160307 - 双击打开 Js 扩展名的附件要保持留心

    Windows Script Host 技术是一门很老的技术,它让 Windows 的自带脚本 VBScript 和 JScript 可以操作 Windows ActiveX 对象,这样的脚本具有本地 ...

  9. delphi调用外部程序打开文件

    delphi调用外部程序打开文件 ShellExecute的各种用法 一.利用系统默认的邮件收发器发送电子邮件 Uses ..., ShellAPI; Var lpHwnd: HWND; lpOper ...

随机推荐

  1. Hadoop基础学习框架

    我们主要使用Hadoop的2个部分:分布式文件存储系统(HDFS)和MapReduce计算模型. 关于这2个部分,可以参考一下Google的论文:The Google File System 和 Ma ...

  2. Android之ViewPager组件实现左右滑动View

    什么是ViewPager VIewPager是安卓3.0之后提供的新特性,继承自ViewGroup,专门用来实现左右滑动切换View的效果.如果想向下兼容需要 android-support-v4.j ...

  3. 移动端HTML5<video>视频播放优化实践[转]

    http://blog.csdn.net/u010918416/article/details/52705732 http://www.xuanfengge.com/html5-video-play. ...

  4. ural 2065. Different Sums

    2065. Different Sums Time limit: 1.0 secondMemory limit: 64 MB Alex is a very serious mathematician ...

  5. Add two numbers [LeetCode]

    You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...

  6. dubbo,gradle,spring build from source

    https://github.com/alibaba/dubbo http://www.csdn.net/article/2012-11-13/2811827-alibaba-Dubbo-Distri ...

  7. python剑指网络篇一

    #coding:utf-8 __author__ = 'similarface' #!/usr/bin/env python import socket #二进制和ASCII互转及其它进制转换 fro ...

  8. Windows下配置cygwin和ndk编译环境

    cygwin安装 正确的安装步骤其实很简单:1. 下载setup-86_64.exe 2. 直接从网上下载安装,选择包时,顶部选择“default”不变 3. 搜索make,勾选make,cmake, ...

  9. RecyclerView(6)自定义RecyclerView.LayoutManager

    A LayoutManager is responsible for measuring and positioning item views within a RecyclerView as wel ...

  10. AbstractExecutorService (未完成)

    AbstractExecutorService是一个实现了ExecutorService的抽象类.主要实现了ExecutorService的invoke方法.