---- 其 实 现 如 下:
//在头文件或.cpp文件的开头
包含文件urlmon.h,定义函数
/////
#include "urlmon.h"
typedef HRESULT STDAPICALLTYPE SHOWHTMLDIALOGFN
(HWND hwndParent, IMoniker
*pmk, VARIANT *pvarArgIn, TCHAR* pchOptions,
VARIANT *pvArgOut);
//////
//函数显示对话框,成功返回TRUE,失败返回FALSE
BOOL ShowHtml()
{
HINSTANCE hinstMSHTML = LoadLibrary
(TEXT("MSHTML.DLL")); //装载动态连
接库
WCHAR url[]=L"HTTP://www.ccw.com.cn";
//此地址名称可直接用html文件名代替
if(hinstMSHTML)//装载动态连接库成功
{
SHOWHTMLDIALOGFN *pfnShowHTMLDialog;
pfnShowHTMLDialog = (SHOWHTMLDIALOGFN*)
GetProcAddress(hinstMSHTML,
TEXT ("ShowHTMLDialog"));
if(pfnShowHTMLDialog)
{
IMoniker *moniker=NULL;
//
if( FAILED(CreateURLMoniker(NULL,
(LPWSTR)url,&moniker ) ))
{
FreeLibrary(hinstMSHTML);
return FALSE;
}
//调用ShowHTMLDialog函数显示URL上的HTML文件
pfnShowHTMLDialog(m_hWnd,moniker,NULL,NULL,NULL);
if(moniker!=NULL)
moniker->Release();
//显示成功,返回TRUE
return TRUE;
}
else //GetProcessAddress失败
return FALSE;
FreeLibrary(hinstMSHTML);
}
else //装载动态连接库失败
return FALSE;
}
文章来源于领测软件测试网 https://www.ltesting.net/