如何在程序中调用Outlook Express写电子邮件
我做了一个简单基于对话框的程序,上面有一静态文本框,我借用了别人的从CStatic派生的类,但是它只是点击它来浏览网页,我希望是E-mail地址,点击它直接调用Outlook Express发送邮件,当然,地址框的内容应为静态文本框的内容,不知如何解决.希望有高手指点.
另外,其程序的实现方法如下:
void CHyperLink::FollowLink()
{
int result = (int) GotoURL(m_strURL, SW_SHOW);
if (result <= HINSTANCE_ERROR) {
MessageBeep(MB_ICONEXCLAMATION); // Unable to follow link
ReportError(result);
} else {
// Mark link as visited and repaint window
m_bVisited = TRUE;
Invalidate();
}
}
HINSTANCE CHyperLink::GotoURL(LPCTSTR url, int showcmd)
{
TCHAR key[MAX_PATH + MAX_PATH];
// First try ShellExecute()
HINSTANCE result = ShellExecute(NULL, _T("open"), url, NULL,NULL, showcmd);
// If it failed, get the .htm regkey and lookup the program
if ((UINT)result <= HINSTANCE_ERROR) {
if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS) {
lstrcat(key, _T("\\shell\\open\\command"));
if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS) {
TCHAR *pos;
pos = _tcsstr(key, _T("\"%1\""));
if (pos == NULL) { // No quotes found
pos = strstr(key, _T("%1")); // Check for %1, without quotes
if (pos == NULL) // No parameter at all...
pos = key+lstrlen(key)-1;
else
*pos = '\0'; // Remove the parameter
}
else
*pos = '\0'; // Remove the parameter
lstrcat(pos, _T(" "));
lstrcat(pos, url);
result = (HINSTANCE) WinExec(key,showcmd);
}
}
}
return result;
}