我现写一个程式,就是在左侧memo中输入文件路径及文件名,点击按钮后可以打开相对应的文件,请问代码应该要怎么写,要用到哪些控件啊?(有点像WINDOWS的运行功能)
我找资料找不到..如果高手可以将其中的关键部分加以说明的话就再好不过了.谢谢
我在学习DELPHI是个初学者,希望可以了解更深入一些.

解决方案 »

  1.   

    memo.lines.loadformfile(path+name)
    纯文本格式的
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    WinExec(pchar('cmd /C '+memo1.Text),SW_HIDE);
    end;
      

  3.   

    在接口处的uses list里,加上 shellapi 单元调用ShellExecute(hWnd: HWND; Operation, FileName, Parameters,Directory: PChar; ShowCmd: Integer): HINST; stdcall;例子:   begin
      ShellExecute(handle, 'open', 'http://www.baidu.com', nil, nil, SW_SHOWNORMAL);
      shellexecute(handle,'open','d:\a.txt',nil,nil,sw_shownormal);
      shellexecute(handle,'open',pansichar(trim(memo1.Text)),nil,nil,sw_shownormal);
    end;
      

  4.   

    uses
      ShellAPI;
    ...
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      try
        ShellExecute(handle, 'open', PAnsiChar(trim(memo1.Text)),nil,nil,SW_SHOWNORMAL);
      except
        Application.MessageBox('打开文件错误','错误');
      end;
    end;
    ...
      

  5.   

    WinExec,适合调用DOS程序
    ShellExecute,Windows程序用这个,相当于开始,运行
    CreateProcess,启动程序进程,可以有更多的控制
      

  6.   

    谢谢大家的回答,可能我表达的不太清楚,我要的是在memo中输入后可以直接打开的....
    smallhand的回答最贴近我的想法,但如果有ShellExecute(handle, 'open', PAnsiChar(trim(memo1.Text)),nil,nil,SW_SHOWNORMAL);
    的说明就更好了