自动调用浏览器或邮件程序
自动调用浏览器或邮件程序
Windows 提供了ShellExecute函数,用来调用外部程序或与某程序关联的文件。
其原型如下:
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
);
如若要自动浏览器程序访问我的主页,程序代码如下:
ShellExecute(Handle,NULL,"http://lmq.4y.com.cn",NULL,NULL,SW_SHOWNORMAL);
若要启动系统默认邮件程序,给我写信,程序代码如下:
ShellExecute(Handle,NULL,"mailto:lmq@4y.com.cn",NULL,NULL,SW_SHOWNORMAL);
浙公网安备 33010602011771号