zoukankan      html  css  js  c++  java
  • 【温故Delphi】双击工程文件打开软件

    问题描述

      大部分软件都有鼠标双击文件,就能打开所关联的软件并打开所选工程,这是如何做到的呢?

      把文件关联到一个程序中,双击文件来启动程序,那么这个文件名称就是这个程序的命令行的一个参数

      所以要想实现双击工程文件打开软件,在程序运行入口必须要处理命令行。

    代码说明  

     1 begin
     2   Application.Initialize;
     3   CreateMainForm();
     4   //GetCommandLine为Win32 API,用于获取命令行内容
     5   HandleCommandLine(GetCommandLine);
     6   if System.ParamCount = 0 then
     7     ExecuteApplication();
     8   Application.Run;
     9 end.
    10 
    11 procedure HandleCommandLine(const ACommandLine: string);
    12 begin
    13   // 解析参数个数:没有参数,直接退出
    14   if ParamCount(ACommandLine) = 0 then Exit;
    15 
    16   S := ParamStr(ACommandLine, 1);
    17 if IsOpenFileMode(S) then 19 begin 20 // 判断当前是否能够打开新工程 21 if not AppInModelState then 22 OpenProjFile(GetLongFileName(S)) 23 else 24 ShowPrompt('请关闭当前窗体,再重新双击打开工程'); 25 end; 26 end;
  • 相关阅读:
    bzoj1297 [SCOI2009]迷路
    bzoj1085 [SCOI2005]骑士精神
    bzoj1009 [HNOI2008]GT考试
    uoj#73 【WC2015】未来程序
    bzoj1016 [JSOI2008]最小生成树计数
    bzoj2818 Gcd
    python递归——汉诺塔
    python参数
    python函数
    为什么会出现__pycache__文件夹?
  • 原文地址:https://www.cnblogs.com/liustdelphi/p/3855209.html
Copyright © 2011-2022 走看看