z

BLOG ARTICLE 개발 | 82 ARTICLE FOUND

  1. 2006.11.24 VS 2005 ActiveX 라이센스 체크 건너띄기
  2. 2006.11.24 IObjectSafety Impl


빌드 후에 생성되는 xxx.lic 파일을 같이 배포해야 한다.

그리고, 로컬 테스트 시에도 .lic 파일이 없으면 자바스크립트에서 바로 에러 빵 뜬다..

컨트롤 클래스 .cpp 파일에 보면 아래의 부분이 있는데 이넘을 수정하면, 걍 스킵시킬 수 있다.

귀차니즘의 압박으로 디테일한 테스트는 다음에.. ㅡ,.ㅡ;;

// 라이센스 문자열입니다.

static const TCHAR BASED_CODE _szLicFileName[] = _T("xxx.lic");

static const WCHAR BASED_CODE _szLicString[] =
L"Copyright (c) 2006 ";


// xxxCtrl::CYUCardAuthCtrlFactory::VerifyUserLicense -
// 사용자 라이센스가 있는지 검사합니다.

BOOL xxxCtrl::xxxCtrlCtrlFactory::VerifyUserLicense()
{
//흠 .. 여기서 걍 return TRUE 하면 라이센스 파일 따로 안넣어 주어도 된다.
//아니면 COleObjectFactory의 m_bLicenseChecked 인가..이넘을 FALSE로 처리해 주던지..
// idl coclass 선언의 licensed 키워드 이용으론 처리가 안되네..
return AfxVerifyLicFile(AfxGetInstanceHandle(), _szLicFileName,
_szLicString);
}

// xxxCtrl::xxxCtrlFactory::GetLicenseKey -
// 런타임 라이센스 키를 반환합니다.

BOOL xxxCtrl::xxxCtrlFactory::GetLicenseKey(DWORD dwReserved,
BSTR FAR* pbstrKey)
{
if (pbstrKey == NULL)
return FALSE;

*pbstrKey = SysAllocString(_szLicString);
return (*pbstrKey != NULL);
}

AND

IObjectSafety Impl

개발/Windows 2006. 11. 24. 13:29


/*
Using MFC
*/
#include "comcat.h"
#include "Objsafe.h"


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);

len = (len > 127) ? 127 : len;

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;
}

void UpdateRegistryPatch(CLSID * pClsId)
{

// mark as safe for scripting--failure OK

HRESULT hr = CreateComponentCategory(CATID_SafeForScripting, L"Controls that are safely scriptable");

if (SUCCEEDED(hr))// only register if category exists
 RegisterCLSIDInCategory(*pClsId, CATID_SafeForScripting);

// don"t care if this call fails
// mark as safe for data initialization

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

if (SUCCEEDED(hr))// only register if category exists
 RegisterCLSIDInCategory(*pClsId, CATID_SafeForInitializing);

// don"t care if this call fails
}


/* Call Part
BOOL CCoclassNameCtrl::CCoclassNameCtrlFactory::UpdateRegistry(BOOL bRegister)
{
if (bRegister)
{
 retVal =  AfxOleRegisterControlClass(...)

 //Call Above
 UpdateRegistryPatch(&m_clsid);
}
}
*/

/*
Using ATL
class ATL_NO_VTABLE CCoclassName :
public ICoclassName,
public IObjectSafetyImpl <CCoclassName, INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA>
*/


AND