如何调用?
调用的dll是要自己编写吗?
这样就可以了。
#import "kernel32.dll"
int WinExec(string NameEx, int dwFlags);
#import
#import "shell32.dll"
int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);
#import
- 开始一个新的应用程序
ShellExecute(Handle, 'open', PChar('c:\test\app.exe'), nil, nil, SW_SHOW);
- 打开记事本,并打开一个文件(系统能识别记事本应用程序的路径,因此我们不必使用绝对路径)
ShellExecute(Handle, 'open', PChar('notepad'), PChar('c:\test\readme.txt'), nil, SW_SHOW);
- 打印一个文档
ShellExecute(Handle, 'print', PChar('c:\test\test.doc'), nil, nil, SW_SHOW);
注意:可能你会看到word暂时的被打开,但它会自动关闭。
- 打开一个HTML页面
ShellExecute(Handle, 'open', PChar('http://www.festra.com/'), nil, nil, SW_SHOW);
- 你能通过一个已经注册的文件类型来打开应用程序
ShellExecute(Handle, 'open', PChar('c:\test\readme.txt'), nil, nil, SW_SHOW);
- 用windows Explorer 打开一个目录
ShellExecute(Handle, 'explore', PChar('c:\windows)', nil, nil, SW_SHOW);
- 运行一个DOS命令并立即返回
ShellExecute(Handle, 'open', PChar('command.com'), PChar('/c copy file1.txt file2.txt'), nil, SW_SHOW);
- 运行一个DOS命令并保持DOS窗口存在
ShellExecute(Handle, 'open', PChar('command.com'), PChar('/k dir'), nil, SW_SHOW);