类似于打开写字板,然后把一个txt文件托拽进去,txt文件就打开了。
或者打开MediaPlayer,托拽一个视频文件进去,视频文件也打开了。
我想这个是不是类似于dos下的程序参数哟~!请大家不要见笑,我一直还没有搞懂呢!

解决方案 »

  1.   

    自问自答:
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Memo1: TMemo;
        procedure FormShow(Sender: TObject);
        procedure WMDropFiles(var Msg: TWMDropFiles); message WM_DROPFILES;
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation
    uses ShellApi;
    {$R *.dfm}procedure TForm1.FormShow(Sender: TObject);
    begin
      DragAcceptFiles(Handle, True);
    end;procedure TForm1.WMDropFiles(var Msg: TWMDropFiles);
    var
      AFileName: array[0..MAX_PATH] of Char;
    begin
      try
        if DragQueryFile(Msg.Drop, 0, AFileName, MAX_PATH) > 0 then
        begin
          Memo1.Lines.LoadFromFile(AFileName);
          Msg.Result := 0;
        end;
      finally
        DragFinish(Msg.Drop);
      end;
    end;end.