ShellExecute 已经很简单了的;;虽然它是win api 但delphi已经把所有的api 都已封装好了;用不着你再写声明;直接调用即可 shellexcute(0,'open','filename',nil,nil,SW_SHOWNORMA)HINSTANCE ShellExecute( HWND hwnd, // handle to parent window LPCTSTR lpOperation, // pointer to string that specifies operation to perform LPCTSTR lpFile, // pointer to filename or folder name string LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters LPCTSTR lpDirectory, // pointer to string that specifies default directory INT nShowCmd // whether file is shown when opened ); hwnd Long,指定一个窗口的句柄,有时候,windows程序有必要在创建自己的主窗口前显示一个消息框 lpOperation String,指定字串“open”来打开lpFlie文档,或指定“Print”来打印它 lpFile String,想用关联程序打印或打开一个程序名或文件名 lpParameters String,如lpszFlie是可执行文件,则这个字串包含传递给执行程序的参数 lpDirectory String,想使用的完整路径 nShowCmd Long,定义了如何显示启动程序的常数值。参考ShowWindow函数的nCmdShow参数
但delphi已经把所有的api 都已封装好了;用不着你再写声明;直接调用即可
shellexcute(0,'open','filename',nil,nil,SW_SHOWNORMA)HINSTANCE ShellExecute( HWND hwnd, // handle to parent window
LPCTSTR lpOperation, // pointer to string that specifies operation to perform
LPCTSTR lpFile, // pointer to filename or folder name string
LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters
LPCTSTR lpDirectory, // pointer to string that specifies default directory
INT nShowCmd // whether file is shown when opened
);
hwnd Long,指定一个窗口的句柄,有时候,windows程序有必要在创建自己的主窗口前显示一个消息框
lpOperation String,指定字串“open”来打开lpFlie文档,或指定“Print”来打印它
lpFile String,想用关联程序打印或打开一个程序名或文件名
lpParameters String,如lpszFlie是可执行文件,则这个字串包含传递给执行程序的参数
lpDirectory String,想使用的完整路径
nShowCmd Long,定义了如何显示启动程序的常数值。参考ShowWindow函数的nCmdShow参数
ShellExecute,ShellExecuteEx,WinExec,CreateProcess都是API,
就算是做一个批处理文件,要运行这个批处理还是要用上述API。