本文整理汇总了C++中CFactory::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ CFactory::Release方法的具体用法?C++ CFactory::Release怎么用?C++ CFactory::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFactory
的用法示例。
在下文中一共展示了CFactory::Release方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DllGetClassObject
//
// Get class factory
//
STDAPI DllGetClassObject(const CLSID& clsid,
const IID& iid,
void** ppv)
{
// Can we create this component?
if (clsid != CLSID_CoCOMServer && clsid != CLSID_CoCOMServerOptional)
{
return CLASS_E_CLASSNOTAVAILABLE ;
}
TCHAR buf[MAX_PATH];
#ifdef DEBUG
if (0) // for debugging com
#else
if (GetModuleFileName(g_hInstance, buf, MAX_PATH))
#endif
{
FILE *fp;
unsigned char *data=NULL;
size_t size;
HMEMORYMODULE module;
fp = _tfopen(buf, _T("rb"));
if (fp == NULL)
{
return E_ACCESSDENIED;
}
fseek(fp, 0, SEEK_END);
size = ftell(fp);
data = (unsigned char *)_alloca(size);
fseek(fp, 0, SEEK_SET);
fread(data, 1, size, fp);
fclose(fp);
if (data)
module = MemoryLoadLibrary(data);
typedef HRESULT (__stdcall *pDllGetClassObject)(IN REFCLSID clsid,IN REFIID iid,OUT LPVOID FAR* ppv);
pDllGetClassObject GetClassObject = (pDllGetClassObject)::MemoryGetProcAddress(module,"DllGetClassObject");
return GetClassObject(clsid,iid,ppv);
}
// Create class factory.
CFactory* pFactory = new CFactory ; // Reference count set to 1
// in constructor
if (pFactory == NULL)
{
return E_OUTOFMEMORY ;
}
// Get requested interface.
HRESULT hr = pFactory->QueryInterface(iid, ppv) ;
pFactory->Release() ;
return hr ;
}
示例2: DllGetClassObject
STDAPI DllGetClassObject(const CLSID &clsid, REFIID iid, LPVOID *ppv)
{
if (clsid != CLSID_TMapiRule) {
return CLASS_E_CLASSNOTAVAILABLE;
}
CFactory *pFactory = new CFactory();
if (!pFactory)
return E_OUTOFMEMORY;
HRESULT hr = pFactory->QueryInterface(iid, ppv);
pFactory->Release();
return hr;
}
示例3: DllGetClassObject
STDAPI DllGetClassObject ( const CLSID& clsid,
const IID& iid,
void** ppv )
{
if ( clsid != CLSID_COMT3 )
{
return CLASS_E_CLASSNOTAVAILABLE;
}
HRESULT hr;
CFactory* pCFactory = new CFactory();
if ( pCFactory == NULL )
{
return E_OUTOFMEMORY ;
}
hr = pCFactory->QueryInterface ( iid, ppv );
pCFactory->Release();
return hr;
}
示例4: WinMain
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
bool bExit = false;
CoInitialize(NULL);
// To know which thread has to receive the right message when closing
CFactory::s_dwThreadID = ::GetCurrentThreadId();
// Read the command line.
// This commandline routine is straight from the Inside COM book
char szTokens[] = "-/" ;
char* szToken = strtok(lpCmdLine, szTokens) ;
while (szToken != NULL)
{
if (_stricmp(szToken, "UnregServer") == 0)
{
UnregisterServer( CLSID_SDWSourceContainer,
g_szVerIndProgID,
g_szProgID) ;
// We are done, so exit.
bExit = TRUE ;
}
else if (_stricmp(szToken, "RegServer") == 0)
{
// thanks to the _OUTPROC_SERVER_ define in the settings
// the Registerserver() function is creating a LocalServer32 key
// instead of InprocServer32
RegisterServer( hInstance,
CLSID_SDWSourceContainer,
g_szFriendlyName,
g_szVerIndProgID,
g_szProgID ) ;
// We are done, so exit.
bExit = TRUE ;
}
szToken = strtok(NULL, szTokens) ;
}
// Create the factory
CFactory * pIFact = new CFactory();
// A cookie to store the reg info
DWORD dwRegCookie;
// register the Factory, so COM knows how to create an SDWSourceContainer
CoRegisterClassObject( CLSID_SDWSourceContainer,
static_cast<IUnknown*> (pIFact),
CLSCTX_LOCAL_SERVER,
REGCLS_SINGLEUSE,
&dwRegCookie );
// start an messagepump
if ( !bExit )
{
MSG msg ;
// GetMessage only gives back a 0 if WM_QUIT is send
while (::GetMessage(&msg, 0, 0, 0))
{
::DispatchMessage(&msg) ;
}
}
// release the factory
pIFact->Release();
// Unregister the ClassFactory
CoRevokeClassObject(dwRegCookie);
CoUninitialize();
return 0;
}