>>>>>> 高分请教:关于在ASP页上通过OLE Automation启动SDI应用程序

silver 2002-08-26 11:28:47
MyApp.exe是由MFC生成的带Automation(完全是AppWizard生成的默认代码)的SDI应用程序,希望在本地安装并注册MyApp.exe后,用户能够在网页上启动该程序,也就是点击网页上一个“启动MyApp”的按钮,MyApp.exe就被启动了。

在asp页面中加入下面的代码:
<Script Language=VBScript>
<!--
sub loadapp()
set obj=createobject("MyApp.Document")
End Sub
//-->
</Script>

打开该asp页后,MyApp.exe的界面闪了一下就消失了。尝试把IE的Internet选项中的安全设置调低,再打开该asp页,MyApp.exe被正常启动。

也就是说在网页里如果不把浏览器安全级别调低,就不能通过createobject正常启动MyApp.exe,这个问题该如何解决?具体怎么做?

只要问题解决,分数不是问题。
...全文
57 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
silver 2002-08-27
  • 打赏
  • 举报
回复
该问题已经解决:

添加以下几个函数,并把下面这行代码加到 InitInstance 中
if (FAILED(DllRegisterServer())) AfxMessageBox("reg fail",NULL,NULL);


HRESULT CreateComponentCategory(CATID catid, WCHAR* catDescription)
{
ICatRegister* pcr = NULL ;
HRESULT hr = S_OK ;

hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr,
NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr);
if (FAILED(hr))
return hr;

// Make sure the HKCR\Component Categories\{..catid...}
// key is registered.
CATEGORYINFO catinfo;
catinfo.catid = catid;
catinfo.lcid = 0x0409 ; // english

// Make sure the provided description is not too long.
// Only copy the first 127 characters if it is.
int len = wcslen(catDescription);
if (len>127)
len = 127;
wcsncpy(catinfo.szDescription, catDescription, len);
// Make sure the description is null terminated.
catinfo.szDescription[len] = '\0';

hr = pcr->RegisterCategories(1, &catinfo);
pcr->Release();

return hr;
}

HRESULT RegisterCLSIDInCategory(REFCLSID clsid, CATID catid)
{
// Register your component categories information.
ICatRegister* pcr = NULL ;
HRESULT hr = S_OK ;
hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr,
NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr);
if (SUCCEEDED(hr))
{
// Register this category as being "implemented" by the class.
CATID rgcatid[1] ;
rgcatid[0] = catid;
hr = pcr->RegisterClassImplCategories(clsid, 1, rgcatid);
}

if (pcr != NULL)
pcr->Release();

return hr;
}

STDAPI DllRegisterServer(void)
{
HRESULT hr; // return for safety functions

// Mark the control as safe for initializing.

hr = CreateComponentCategory(CATID_SafeForInitializing, L"Controls safely initializable from persistent data!");
if (FAILED(hr)) return hr;

hr = RegisterCLSIDInCategory(clsid, CATID_SafeForInitializing);
if (FAILED(hr)) return hr;

// Mark the control as safe for scripting.

hr = CreateComponentCategory(CATID_SafeForScripting, L"Controls safely scriptable!");
if (FAILED(hr)) return hr;

hr = RegisterCLSIDInCategory(clsid, CATID_SafeForScripting);
if (FAILED(hr)) return hr;

return NOERROR;
}

MeXP 2002-08-26
  • 打赏
  • 举报
回复
如果真是IE的安全等级问题,那么我觉得没有好的办法
dgz01 2002-08-26
  • 打赏
  • 举报
回复
UP,高难

*****
打工好辛苦
*****
钞票好难赚
*****
编程好伤神
*****
光阴好易混
*****

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧