ShowHTMLDialog的用法
一个好用的函数ShowHTMLDialog, mshtml.dll导出的
可以用它来执行一些脚本. 很方便
#include "stdafx.h"
#include <urlmon.h>
#pragma comment(lib, "urlmon.lib")
typedef HRESULT STDAPICALLTYPE MYSHOWHTMLDIALOGFN
(HWND hwndParent, IMoniker
*pmk, VARIANT *pvarArgIn, TCHAR* pchOptions,
VARIANT *pvArgOut);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MYSHOWHTMLDIALOGFN* pFunc;
HINSTANCE hLib = ::LoadLibrary("mshtml.dll");
if (hLib != INVALID_HANDLE_VALUE)
{
pFunc = (MYSHOWHTMLDIALOGFN*)::GetProcAddress(hLib, "ShowHTMLDialog");
if (pFunc)
{
LPCWSTR str = L"http://www.sina.com";
IMoniker *pmoniker = NULL;
if (SUCCEEDED(::CreateURLMoniker(NULL, str, &pmoniker)))
{
char *pOptions = (char*) L"dialogHeight:280px;dialogWidth:430px;help:no;status:no;scroll:no";
//这里必须是UNICODE型的字符串.否则更改不了窗口的大小
pFunc(NULL, pmoniker, NULL, pOptions, NULL);
}
else
MessageBox(NULL, "CreateURLMoniker fails", "Error..", MB_OK);
}
else
MessageBox(NULL, "GetProcAddress fails", "Error..", MB_OK);
::FreeLibrary(hLib);
}
else
MessageBox(NULL, "LoadLibrary fails", "Error..", MB_OK);
return 0;
}