本文整理汇总了C++中CLSIDFromProgID函数的典型用法代码示例。如果您正苦于以下问题:C++ CLSIDFromProgID函数的具体用法?C++ CLSIDFromProgID怎么用?C++ CLSIDFromProgID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CLSIDFromProgID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
//------------------------------------------------------------------*
STDMETHODIMP
CCustomConnect::CreateControlManagement(/*[in, string]*/ BSTR sInit, /*[out]*/ IUnknown **ppControlMgt)
{
USES_CONVERSION;
CSingleLock lock(&cs, TRUE);
if (ppControlMgt == NULL)
return E_POINTER;
CString strInit = StripCommParam(sInit);
if (!CheckInitString(strInit))
return E_INVALIDARG;
CLSID guid;
TCHAR szProgID[256];
lstrcpy(szProgID, g_ProgID_ControlMgt);
lstrcat(szProgID, strInit);
LPCWSTR lpwstrProgID = T2W(szProgID);
HRESULT hr = CLSIDFromProgID(lpwstrProgID, &guid);
if (FAILED(hr)) {
hr = _Module.RegisterServerInstance(strInit);
hr = CLSIDFromProgID(lpwstrProgID, &guid);
for(int i=0; FAILED(hr) && i<100; i++) { // W2K: SP2-HACK
Sleep(100);
hr = CLSIDFromProgID(lpwstrProgID, &guid);
}
}
if (FAILED(hr))
return hr;
//try to avoid second instance...
CComPtr<IUnknown> pDummy;
hr = CreateVarSession(sInit, &pDummy);
if (FAILED(hr))
return hr;
return CoCreateInstance(guid, NULL, CLSCTX_ALL, IID_IUnknown, (void**)ppControlMgt);
}
示例2: switch
void
Foobar::EnableDisable()
{
static BOOL old = FALSE;
if(m_enabled == old) return;
switch(old){ //stop ...
case 0: break;
case 1: COM_Stop(); break; //COM
case 2: m_needPoll = FALSE; break; //MLT
}
switch(m_enabled){ //start ...
case 0: {
if(loaded)
NotifyInfoChanged();
} break;
case 1: {
CLSID clsid;
if( (SUCCEEDED(CLSIDFromProgID(L"Foobar2000.ApplicationHelper.0.7", &clsid))) &&
(COM_Start()) ) break; //COM is full install (host and server)
else
if( (SUCCEEDED(CLSIDFromProgID(L"Foobar2000.Application0.7", &clsid))) ) {
m_needPoll = COM_ConnectServer() ? FALSE : TRUE;
break; //COM is install (only server)
}
}
//fall through (no com)
case 2: {
m_enabled = 2;
m_needPoll = FALSE;
//MLT_Start();
} break; //MLT
}
old = m_enabled;
}
示例3: wmain
int wmain(int argc, wchar_t *argv[])
{
if (argc != 2)
{
std::wcout << L"usage:" << std::endl
<< L" LookupProgID.exe <ProgID>" << std::endl;
return 0;
}
HRESULT hr;
hr = CoInitialize(NULL);
if (FAILED(hr))
{
std::wcout << L"CoInitialize failed" << std::endl;
return 1;
}
CLSID clsid;
hr = CLSIDFromProgID(argv[1], &clsid);
if (SUCCEEDED(hr))
{
LPOLESTR s;
hr = StringFromCLSID(clsid, &s);
if (SUCCEEDED(hr))
{
std::wcout << "CLSID: " << s << std::endl;
CoTaskMemFree(s);
}
}
CoUninitialize();
return 0;
}
示例4: Init
HRESULT _IFUNC BOleInProcHandler::Init(PIBDataProvider pDP,
PIBPart pP, LPCOLESTR szProgId, BOOL fHatchWnd)
{
HRESULT hr;
// Initialize back pointers
//
pProvider = pDP;
pPart = pP;
CLSID cid;
if (SUCCEEDED(hr = CLSIDFromProgID(szProgId, &cid))) {
// create the default handler, which will launch the exe server
//
OleCreateEmbeddingHelper(cid, AsPIUnknown(pObjOuter),
EMBDHLP_INPROC_HANDLER | EMBDHLP_DELAYCREATE, NULL, IID_IUnknown,
&(LPVOID)pDefHandler);
// initialize default IPS
//
hr = pDefHandler->QueryInterface(IID_IBSite, &(LPVOID)pDefSite);
if (SUCCEEDED(hr)) {
pDefSite->Release(); // prevent aggregation deadlock
hr = pDefSite->Init(pDP, pP, szProgId, fHatchWnd);
}
}
return hr;
}
示例5: NS_ENSURE_ARG_POINTER
HRESULT XPCDispObject::COMCreateInstance(XPCCallContext & ccx, BSTR className,
PRBool enforceSecurity,
IDispatch ** result)
{
NS_ENSURE_ARG_POINTER(result);
// Turn the string into a CLSID
_bstr_t bstrName(className);
CLSID classID = CLSID_NULL;
HRESULT hr = CLSIDFromString(bstrName, &classID);
if(FAILED(hr))
hr = CLSIDFromProgID(bstrName, &classID);
if(FAILED(hr) || ::IsEqualCLSID(classID, CLSID_NULL))
return hr;
// If the caller cares about security do the necessary checks
// This results in the object being instantiated, so we'll use
// it
if(enforceSecurity)
return SecurityCheck(ccx, classID, result);
CComPtr<IDispatch> disp;
#ifdef JAXER
hr = disp.CoCreateInstance(classID, NULL, CLSCTX_SERVER);
#else
hr = disp.CoCreateInstance(classID);
#endif /* JAXER */
if(FAILED(hr))
return hr;
disp.CopyTo(result);
return S_OK;
}
示例6: CHECKPARAM
HRESULT tCOMUtil::ProgID2CLSID(CLSID *pClsid, const char *ProgID)
{
CHECKPARAM(pClsid);
// tests whether we already have a CLSID
wchar_t* wcProgId = NULL;
HRESULT hr = S_OK;
if(ProgID[0] == '{')
{
wcProgId = (wchar_t*) malloc( (strlen(ProgID) + 1) * sizeof(wchar_t));
mbstowcs(wcProgId, ProgID, strlen(ProgID)+1);
hr = CLSIDFromString(wcProgId, pClsid);
free(wcProgId);
wcProgId = NULL;
return hr;
}
/* converte ProgID para OLESTR */
wcProgId = (wchar_t*) malloc( (strlen(ProgID) + 1) * sizeof(wchar_t));
mbstowcs(wcProgId, ProgID, strlen(ProgID)+1);
hr = CLSIDFromProgID(wcProgId, pClsid);
free(wcProgId);
wcProgId = NULL;
return hr;
}
示例7: iOleControlCreateMethod
static int iOleControlCreateMethod(Ihandle* ih, void **params)
{
CLSID clsid;
if (!params || !(params[0]))
return IUP_ERROR;
char *progID = (char*)params[0];
/* free the data alocated by IupCanvas */
if (ih->data) free(ih->data);
ih->data = iupALLOCCTRLDATA();
/* change the IupCanvas default values */
iupAttribSetStr(ih, "BORDER", "NO");
/* IupCanvas callbacks */
IupSetCallback(ih,"RESIZE_CB",(Icallback)iOleControlResize_CB);
size_t len = strlen(progID)+1;
wchar_t* wcProgId = (wchar_t*) malloc(len * sizeof(wchar_t));
mbstowcs(wcProgId, progID, len);
HRESULT hr = CLSIDFromProgID(wcProgId, &clsid);
free(wcProgId);
if(FAILED(hr))
return IUP_ERROR;
ih->data->olehandler = new tOleHandler();
if (ih->data->olehandler->Create(&clsid) == CREATE_FAILED)
return IUP_ERROR;
return IUP_NOERROR;
}
示例8: sendPUTRequest
void sendPUTRequest(const std::string& server, const std::string& data)
{
HRESULT hr;
CLSID clsid;
IWinHttpRequest *pIWinHttpRequest = NULL;
_variant_t varFalse(false);
_variant_t varData(data.c_str());
hr = CLSIDFromProgID(L"WinHttp.WinHttpRequest.5.1", &clsid);
if (SUCCEEDED(hr)){
hr = CoCreateInstance(clsid, NULL,
CLSCTX_INPROC_SERVER,
IID_IWinHttpRequest,
(void **)&pIWinHttpRequest);
}
if (SUCCEEDED(hr)){
hr = pIWinHttpRequest->SetTimeouts(1000, 1000, 2000, 1000);
}
if (SUCCEEDED(hr)){
_bstr_t method("PUT");
_bstr_t url(server.c_str());
hr = pIWinHttpRequest->Open(method, url, varFalse);
}
if (SUCCEEDED(hr)){
hr = pIWinHttpRequest->Send(varData);
}
pIWinHttpRequest->Release();
}
示例9: CLEAROUT
STDMETHODIMP TCUtilImpl::CreateObject(BSTR bstrProgID, BSTR bstrComputer,
IUnknown** ppUnk)
{
// Initialize the [out] parameter
CLEAROUT(ppUnk, (IUnknown*)NULL);
// Convert the specified ProgID to a CLSID
CLSID clsid;
if (!BSTRLen(bstrProgID))
return E_INVALIDARG;
RETURN_FAILED(CLSIDFromProgID(bstrProgID, &clsid));
// Initialize the COSERVERINFO and MULTI_QI structures
COSERVERINFO csi = {0, bstrComputer, NULL, 0};
MULTI_QI mqi[] =
{
{&IID_IUnknown , NULL, S_OK},
{&IID_IDispatch , NULL, S_OK},
{&IID_IConnectionPointContainer, NULL, S_OK},
};
const static ULONG cMQI = sizeofArray(mqi);
// Determine if the specified computer name is definitely local
bool bLocalForSure = true;
if (BSTRLen(bstrComputer))
{
TCHAR szLocal[MAX_COMPUTERNAME_LENGTH + 1];
DWORD cchLocal = sizeofArray(szLocal);
GetComputerName(szLocal, &cchLocal);
USES_CONVERSION;
bLocalForSure = !_tcsicmp(szLocal, OLE2CT(bstrComputer));
}
DWORD dwClsCtx = bLocalForSure ? CLSCTX_SERVER : CLSCTX_REMOTE_SERVER;
// Attempt to create the instance
HRESULT hr = CoCreateInstanceEx(clsid, NULL, dwClsCtx, &csi, cMQI, mqi);
if (FAILED(hr))
{
_TRACE_BEGIN
_TRACE_PART1("TCCreateObject failed: hr=0x%08X", hr);
_TRACE_PART1(", dwClsCtx=%hs", (CLSCTX_SERVER == dwClsCtx) ?
"CLSCTX_SERVER" : "CLSCTX_REMOTE_SERVER");
_TRACE_PART1(", ProgID=\"%ls\"", bstrProgID);
_TRACE_PART1(", Computer= \"%ls\"\n", bstrComputer ?
bstrComputer : L"");
_TRACE_END
return hr;
}
// Copy the IUnknown interface pointer to the [out] parameter
*ppUnk = mqi[0].pItf;
// Release each interface not being returned
for (ULONG i = 1; i < cMQI; ++i)
if (mqi[i].pItf)
mqi[i].pItf->Release();
// Return the result of the QI for IUnknown
return mqi[0].hr;
}
示例10: StartExcel
BOOL CXLAutomation::StartExcel()
{
CLSID clsExcelApp;
// if Excel is already running, return with current instance
if (m_pdispExcelApp != NULL)
return TRUE;
/* Obtain the CLSID that identifies EXCEL.APPLICATION
* This value is universally unique to Excel versions 5 and up, and
* is used by OLE to identify which server to start. We are obtaining
* the CLSID from the ProgID.
*/
if (FAILED(CLSIDFromProgID(L"Excel.Application", &clsExcelApp)))
{
MessageBox(NULL, _T("Cannot obtain CLSID from ProgID"), "Failed", MB_OK | MB_ICONSTOP);
return FALSE;
}
// start a new copy of Excel, grab the IDispatch interface
if (FAILED(CoCreateInstance(clsExcelApp, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void**)&m_pdispExcelApp)))
{
MessageBox(NULL, _T("Cannot start an instance of Excel for Automation."), "Failed", MB_OK | MB_ICONSTOP);
return FALSE;
}
return TRUE;
}
示例11: Host_CreateObject
static HRESULT WINAPI Host_CreateObject(IHost *iface, BSTR ProgID, BSTR Prefix,
IDispatch **out_Dispatch)
{
IUnknown *unk;
GUID guid;
HRESULT hres;
TRACE("(%s %s %p)\n", wine_dbgstr_w(ProgID), wine_dbgstr_w(Prefix), out_Dispatch);
if(Prefix && *Prefix) {
FIXME("Prefix %s not supported\n", debugstr_w(Prefix));
return E_NOTIMPL;
}
hres = CLSIDFromProgID(ProgID, &guid);
if(FAILED(hres))
return hres;
hres = CoCreateInstance(&guid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER|CLSCTX_REMOTE_SERVER,
&IID_IUnknown, (void**)&unk);
if(FAILED(hres))
return hres;
hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)out_Dispatch);
IUnknown_Release(unk);
return hres;
}
示例12: get_content_type
static enum content get_content_type(LPCOLESTR name, CLSID *control_id)
{
WCHAR new_urlW[MAX_PATH];
DWORD size = MAX_PATH;
WCHAR mshtml_prefixW[] = {'m','s','h','t','m','l',':','\0'};
if (!name || !name[0])
{
WARN("name %s\n", wine_dbgstr_w(name));
return IsEmpty;
}
if (CLSIDFromString(name, control_id) == S_OK ||
CLSIDFromProgID(name, control_id) == S_OK)
return IsGUID;
if (PathIsURLW (name) ||
UrlApplySchemeW(name, new_urlW, &size, URL_APPLY_GUESSSCHEME|URL_APPLY_GUESSFILE) == S_OK)
{
*control_id = CLSID_WebBrowser;
return IsURL;
}
if (!strncmpiW(name, mshtml_prefixW, 7))
{
FIXME("mshtml prefix not implemented\n");
*control_id = CLSID_WebBrowser;
return IsHTML;
}
return IsUnknown;
}
示例13: CLSIDFromProgID
void excelreader::InstanceExcelWorkbook(int visible)
{
// get CLSID of excel
CLSID clsid;
HRESULT hr = CLSIDFromProgID(L"Excel.Application", &clsid);
if (FAILED(hr))
{
throw ExcelException("start excel failed. confirm excel installed");
}
// instance app
// hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER,
// IID_IDispatch, (void **)&pXlApp);
hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void **)&pXlApp);
if (FAILED(hr))
{
throw ExcelException("start excel failed. confirm excel installed");
}
// display, set Application.Visible to 1
_variant_t x((long)visible);
AutoWrap(DISPATCH_PROPERTYPUT, NULL, pXlApp, L"Visible", 1, (VARIANT)x);
// get workbooks
_variant_t result;
AutoWrap(DISPATCH_PROPERTYGET, &result, pXlApp, L"Workbooks", 0);
pXlBooks = result.Detach().pdispVal;
}
示例14: CLSIDFromProgID
void CAboutDlg::FillObjectVersion(LPCTSTR szProgID)
{
CLSID cls;
USES_CONVERSION;
CLSIDFromProgID(T2W(szProgID), &cls);
FillObjectVersion(cls);
}
示例15: ImportDotXSI
void ImportDotXSI()
{
CComPtr<XSIApplication> l_pApplication;
CLSID lclsid;
CLSIDFromProgID(L"XSI.Application", &lclsid );
CoCreateInstance(lclsid, NULL, CLSCTX_INPROC, IID_XSIApplication, (void **)&l_pApplication);
_variant_t args;
_variant_t v;
long l = 0 ;
SAFEARRAY* psa = NULL;
const int cntArgs = 1 ;
psa = ::SafeArrayCreateVector( VT_VARIANT, 0, cntArgs );
args.vt = VT_VARIANT | VT_ARRAY;
args.parray = psa;
v = _bstr_t ( "c:\\__tmp.xsi" );
SafeArrayPutElement(psa, &l, &v);
l++;
// more args?
//
VARIANT l_vOutValue;
l_pApplication->ExecuteScriptCommand( _bstr_t( L"SIImportDotXSIFile" ), args, &l_vOutValue ) ;
}