当前位置:IT168首页 > 技术开发 > 修改DllRegisterServer函数
[收藏此页] [打印] [推荐] [评论]

步步学ACTIVEX网页控件开发:创建安全的ActiveX控件

责任编辑:胡铭娅作者:IT168 陈良乔   2009-05-13   

  2.修改DllRegisterServer函数: 

STDAPI DllRegisterServer(void)
{
    HRESULT hr;    
// HResult used by Safety Functions
    AFX_MANAGE_STATE(_afxModuleAddrThis);
    
if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
      
return ResultFromScode(SELFREG_E_TYPELIB);
    
if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
      
return ResultFromScode(SELFREG_E_CLASS);
    
// 为初始化标记控件为安全控件                                      
    hr = CreateComponentCategory(CATID_SafeForInitializing,
         L
"Controls safely initializable from persistent data!");
    
if (FAILED(hr))
      
return hr;
    hr
= RegisterCLSIDInCategory(CLSID_SafeItem,
         CATID_SafeForInitializing);
    
if (FAILED(hr))
        
return hr;
  
// 为脚本标记控件为安全控件                                        
    hr = CreateComponentCategory(CATID_SafeForScripting,                                 L"Controls safely  scriptable!");
    
if (FAILED(hr))
        
return hr;
    hr
= RegisterCLSIDInCategory(CLSID_SafeItem,                         CATID_SafeForScripting);
    
if (FAILED(hr))
        
return hr;
    
return NOERROR;
}

  3.修改 DllUnregisterServer函数: 

STDAPI DllUnregisterServer(void)
{
    HRESULT hr;    
// HResult used by Safety Functions
    AFX_MANAGE_STATE(_afxModuleAddrThis);
    
if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor))
      
return ResultFromScode(SELFREG_E_TYPELIB);
    
if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE))
      
return ResultFromScode(SELFREG_E_CLASS);
    hr
=UnRegisterCLSIDInCategory(CLSID_SafeItem,                      CATID_SafeForInitializing);
    
if (FAILED(hr))
      
return hr;
    hr
=UnRegisterCLSIDInCategory(CLSID_SafeItem,
                        CATID_SafeForScripting);
    
if (FAILED(hr))
      
return hr;
    
return NOERROR;
}
上一页12
3
下一页
收藏到: 添加到“百度搜藏”添加到“QQ书签”添加到“Google书签”添加到“Yahoo收藏”添加到“和讯网摘”
本文欢迎转载,转载请注明:转载自IT168 [ http://www.it168.com/ ]
本文链接:http://tech.it168.com/a2009/0513/276/000000276191_2.shtml
友情推介