Ejemplo n.º 1
1
    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;
    }
//------------------------------------------------------------------*
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);
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
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();
}
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
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;
}
Ejemplo n.º 7
0
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;
}
Ejemplo n.º 8
0
void CAboutDlg::FillObjectVersion(LPCTSTR szProgID)
{
	CLSID cls;
	USES_CONVERSION;
	CLSIDFromProgID(T2W(szProgID), &cls);
	FillObjectVersion(cls);
}
Ejemplo n.º 9
0
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;
}
Ejemplo n.º 10
0
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;
}
Ejemplo n.º 11
0
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;
}
Ejemplo n.º 12
0
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 ) ;


}
Ejemplo n.º 13
0
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;
}
Ejemplo n.º 14
0
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;
}
Ejemplo n.º 15
0
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;

}
Ejemplo n.º 16
0
///////////////////////////////////////////////////////////////////////////////
// Helperroutinen
HRESULT LoadSearchEngine (IPropertyActionSequence *pISeq, LPCSTR pcKey)
{
// ClassID aus Registry besorgen
CLSID clsID;
HRESULT hr = CLSIDFromProgID (WideString(pcKey), &clsID);

	if (FAILED(hr)) return hr;		// nichts gefunden

	COM_TRY {
	// Objekt instantiieren
	WPropertyAction WAct (clsID);		// throws hr

	// Objekt initialisieren
		{
		WPersistStreamInit Init (WAct);	// throws hr;
		HRESULT hr = Init -> InitNew();

			if (FAILED(hr)) {
				if (hr != E_ABORT)
					return hr;
				return S_FALSE;			// darf mit E_ABORT fehlschlagen
			}
		}
		
	// zur Sequence hinzufügen
		THROW_FAILED_HRESULT(pISeq -> AddAction (WAct));
		
	} COM_CATCH;
	return S_OK;
}
Ejemplo n.º 17
0
DmSoft::DmSoft(){
	WinExec("regsvr32 /s dm.dll", SW_HIDE);
	//?注册
	CoInitialize(NULL);
	CLSID clsid;
	//?利用“根名称.类名”获取CLSID,&就是把指针给函数,也就是传址
	HRESULT hr = CLSIDFromProgID(OLESTR("dm.dmsoft"), &clsid);
	dmSoft.CreateDispatch(clsid);
}
Ejemplo n.º 18
0
CTypeScript::CTypeScript() : m_ref(1)
{
	InterlockedIncrement(&ulLockCount);

	CLSID CLSID_Script;
	CLSIDFromProgID(L"JScript", &CLSID_Script);

	CoCreateInstance(CLSID_Script, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_js));
}
Ejemplo n.º 19
0
int StartPlugin(){

    //Create an instance of our VB COM object, and execute
	//one of its methods so that it will load up and show a UI
	//for us, then it uses our other exports to access olly plugin API
	//methods

	CLSID      clsid;
	HRESULT	   hr;
    LPOLESTR   p = OLESTR("IDACompare.CPlugin");

    hr = CoInitialize(NULL);

	 hr = CLSIDFromProgID( p , &clsid);
	 if( hr != S_OK  ){
		 MessageBox(0,"Failed to get Clsid from string\n","",0);
		 return 0;
	 }

	 // create an instance and get IDispatch pointer
	 hr =  CoCreateInstance( clsid,
							 NULL,
							 CLSCTX_INPROC_SERVER,
							 IID_IDispatch  ,
							 (void**) &IDisp
						   );

	 if ( hr != S_OK )
	 {
	   MessageBox(0,"CoCreate failed","",0);
	   return 0;
	 }

	 OLECHAR *sMethodName = OLESTR("DoPluginAction");
	 DISPID  dispid; // long integer containing the dispatch ID

	 // Get the Dispatch ID for the method name
	 hr=IDisp->GetIDsOfNames(IID_NULL,&sMethodName,1,LOCALE_USER_DEFAULT,&dispid);
	 if( FAILED(hr) ){
	    MessageBox(0,"GetIDS failed","",0);
		return 0;
	 }

	 DISPPARAMS dispparams;
	 VARIANTARG vararg[1]; //function takes one argument
	 VARIANT    retVal;

	 VariantInit(&vararg[0]);
	 dispparams.rgvarg = &vararg[0];
	 dispparams.cArgs = 0;  // num of args function takes
	 dispparams.cNamedArgs = 0;

	 // and invoke the method
	 hr=IDisp->Invoke( dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, &retVal, NULL, NULL);

	 return 0;
}
Ejemplo n.º 20
0
/* {{{ proto int com_load(string module_name)
   Loads a COM module */
void php3_COM_load(INTERNAL_FUNCTION_PARAMETERS)
{
	pval *module_name;
	CLSID clsid;
	HRESULT hr;
	OLECHAR *ProgID;
	IUnknown FAR *i_unknown = NULL;
	IDispatch FAR *i_dispatch = NULL;
	char *error_message;
	char *clsid_str;
	int i;

	if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &module_name)==FAILURE) {
		WRONG_PARAM_COUNT;
	}

	convert_to_string(module_name);
	ProgID = (OLECHAR *) emalloc(sizeof(OLECHAR)*(module_name->value.str.len+1));
	for (i=0; i<module_name->value.str.len; i++) {
		ProgID[i] = module_name->value.str.val[i];
	}
	ProgID[i] = 0;
	hr=CLSIDFromProgID(ProgID, &clsid);
	efree(ProgID);

	/* obtain CLSID */
	if (FAILED(hr)) {
		error_message = _php3_COM_error_message(hr);
		php3_error(E_WARNING,"Invalid ProgID:  %s\n", error_message);
		LocalFree(error_message);
		RETURN_FALSE;
	}

	/* obtain IUnknown */
	if (FAILED(hr=CoCreateInstance(&clsid, NULL, CLSCTX_ALL, &IID_IUnknown, (void FAR* FAR*) &i_unknown))) {
		error_message = _php3_COM_error_message(hr);
		clsid_str = _php3_string_from_clsid(&clsid);
		php3_error(E_WARNING,"Unable to obtain IUnknown interface for CLSID %s:  %s",clsid_str,error_message);
		LocalFree(error_message);
		efree(clsid_str);
		RETURN_FALSE;
	}

	/* obtain IDispatch */
	if (FAILED(hr=i_unknown->lpVtbl->QueryInterface(i_unknown, &IID_IDispatch, (void FAR* FAR*) &i_dispatch))) {
		error_message = _php3_COM_error_message(hr);
		clsid_str = _php3_string_from_clsid(&clsid);
		php3_error(E_WARNING,"Unable to obtain IDispatch interface for CLSID %s:  %s",clsid_str,error_message);
		LocalFree(error_message);
		efree(clsid_str);
		RETURN_FALSE;
	}
	i_unknown->lpVtbl->Release(i_unknown);

	RETURN_LONG(php3_list_insert(i_dispatch,le_idispatch));
}
CLSID ServerConnection::getCLSID()
{
	FRL_EXCEPT_GUARD();
	CLSID server_clsid = GUID_NULL;
	#if( FRL_CHARACTER == FRL_CHARACTER_UNICODE )
		if( FAILED(CLSIDFromProgID( server_id.c_str(), &server_clsid)) )
		{
			if( UuidFromString( (unsigned short*)server_id.c_str(), &server_clsid) != RPC_S_OK )
				FRL_THROW_S_CLASS( NotResolveProgID );
		}
	#else
		if( FAILED(CLSIDFromProgID( string2wstring( server_id ).c_str(), &server_clsid)) )
		{
			if( UuidFromString( (unsigned char*)server_id.c_str(), &server_clsid) != RPC_S_OK )
				FRL_THROW_S_CLASS( NotResolveProgID );
		}	
	#endif // FRL_CHARACTER_UNICODE
	return server_clsid;
}
Ejemplo n.º 22
0
void PropertySequence_cmd_AddAction (ebHTHREAD hThread, int iNumArgs, ebARGS lpArgs)
{
	BASIC_OP_TRACE(PropertySequence_cmd_AddAction);

WPropertyActionSequence Seq ((IPropertyActionSequence *)ebGetObject (lpArgs, 1));
ebHSUB hStr = ebGetString (lpArgs, 2);

	if (NULL != hStr) {
		USES_CONVERSION;

	LPSTR lpstr = ebLockString (hThread, hStr);

		BASIC_OP_TRACE2(lpstr);

	CLSID clsID;
	HRESULT hr = CLSIDFromString (A2OLE(lpstr), &clsID);

		if (FAILED(hr))
			hr = CLSIDFromProgID (A2OLE(lpstr), &clsID);

		if (SUCCEEDED(hr)) {
		CComVariant v2 (MakeVARIANT (hThread, iNumArgs, lpArgs, 3));

			if (VT_ERROR == V_VT(&v2)) {
			// nur ein Parameter gegeben
			CALPCLSID cal;
			const CLSID *pClsID = &clsID;

				memset(&cal, '\0', sizeof(CALPCLSID));
				cal.cElems = 1;
				cal.ppElems = &pClsID;
				Seq -> AddActionsByCLSID (&cal);
			
			} else {
			// 2. Parameter auswerten
				try {
				WPropertyAction WAct (clsID);	// throws hr

					if (FAILED(InitFromData (WAct, v2))) {
					// kann nicht mit Daten initialisiert werden, also normales Init
					WPersistStreamInit Init (WAct);			// throws hr

						THROW_FAILED_HRESULT(Init -> InitNew());
					}

					THROW_FAILED_HRESULT(Seq -> AddAction (WAct));

				} catch (_com_error&) {
					;
				}
			}
		}
		ebUnlockString (hThread, hStr);
	}
}
Ejemplo n.º 23
0
HRESULT CTCPropBagOnRegKey::_GetObjectCLSID(const _bstr_t& strName,
  CLSID& clsid, CRegKey& subkey, _bstr_t& strObjectID, IErrorLog* pErrorLog)
{
  USES_CONVERSION;

  // Clear the specified clsid, subkey, and strObjectID parameters
  clsid = CLSID_NULL;
  subkey.Close();
  strObjectID.Empty();

  // Open the subkey with the specified name
  if (!strName.length())
    subkey = m_key;
  else if (!m_key.Exists(strName) || !subkey.Open(m_key, strName))
    return HRESULT_FROM_WIN32(GetLastError());

  // Use local resources for string loading
  MCLibRes res;

  // Read the object's CLSID string value
  HRESULT hr;
  _bstr_t strDesc;
  if (subkey.GetString(m_szCLSID, strObjectID))
  {
    // Convert the object's CLSID string to a CLSID
    LPOLESTR pszObjectID = const_cast<LPOLESTR>(T2COLE(strObjectID));
    hr = CLSIDFromString(pszObjectID, &clsid);
    if (SUCCEEDED(hr))
      return hr;

    // Format an error description string   
    strDesc.Format(IDS_FMT_FAIL_CONVERT_CLSID, strObjectID);
  }
  else if (subkey.GetString(m_szProgID, strObjectID))
  {
    // Convert the object's ProgID string to a CLSID
    hr = CLSIDFromProgID(T2COLE(strObjectID), &clsid);
    if (SUCCEEDED(hr))
      return hr;

    // Format an error description string
    strDesc.Format(IDS_FMT_FAIL_CONVERT_CLSID, strObjectID);
  }
  else
  {
    // Save the last error
    hr = HRESULT_FROM_WIN32(GetLastError());

    // Format an error description string
    strDesc.LoadString(IDS_FAIL_READ_CLSID);
  }

  // Log the error and return
  return LogError("GetObjectCLSID", strDesc, hr, T2COLE(strName), pErrorLog);
}
Ejemplo n.º 24
0
HRESULT AFXAPI AfxGetClassIDFromString(LPCTSTR lpsz, LPCLSID lpClsID)
{
	USES_CONVERSION;

	HRESULT hr;
	if (lpsz[0] == '{')
		hr = CLSIDFromString((LPOLESTR)T2COLE(lpsz), lpClsID);
	else
		hr = CLSIDFromProgID(T2COLE(lpsz), lpClsID);
	return hr;
}
Ejemplo n.º 25
0
static void test_CLSIDFromProgID(void)
{
    CLSID clsid;
    HRESULT hr = CLSIDFromProgID(devicedotone, &clsid);
    ok(hr == S_OK, "CLSIDFromProgID failed with error 0x%08lx\n", hr);
    ok(IsEqualCLSID(&clsid, &CLSID_CDeviceMoniker), "clsid wasn't equal to CLSID_CDeviceMoniker\n");

    hr = CLSIDFromString((LPOLESTR)devicedotone, &clsid);
    ok_ole_success(hr, "CLSIDFromString");
    ok(IsEqualCLSID(&clsid, &CLSID_CDeviceMoniker), "clsid wasn't equal to CLSID_CDeviceMoniker\n");
}
Ejemplo n.º 26
0
myOPC::myOPC(wchar_t *ServerName):TimeBias(0),PercentDeadband(0.0),Connected(false)
{
	//подключение к серверу
	#ifdef _mDEBUG
	log="Конструктор: \n";
	log="Подключение к OPC серверу "+String(ServerName)+" \n";
	log+="Инициализация COM библиотек\n";
	#endif
	result=CoInitialize(NULL); //подготовка СОМ библиотек к работе
	#ifdef _mDEBUG
	if (result==S_OK||result==S_FALSE)
	{
		log+="OK\n";
	}else
	{
		log+="FAIL\n";
	}
	log+="Получение идентификатора класса сервера по его имени (clsid)\n";
	#endif
	// получение идентификатора класса по имени сервера
	result=CLSIDFromProgID(ServerName,&clsid);
	if (result!=S_OK)
	{
	#ifdef _mDEBUG
		log+="FAIL\n";
	#endif
		return;
	}
	#ifdef _mDEBUG
	else
	{
		log+="OK\n";
	}
	log+="Получение адреса сервера (pIOPCServer)\n";
	#endif
	// получение адреса сервера
	result=CoCreateInstance(clsid,NULL,CLSCTX_LOCAL_SERVER,IID_IOPCServer,(void**)&pIOPCServer);
	if (result!=S_OK)
	{
	#ifdef _mDEBUG
		log+="FAIL\n";
	#endif
		return;
	}
	#ifdef _mDEBUG
	else
	{
		log+="OK\n";
	}
	log+="Соединение с сервером установлено\n\n";
	#endif
	Connected=true;
	Groups.clear();
}
Ejemplo n.º 27
0
/**
 * Checks to see if Extend is registered for OLE automation
 */
bool ExtendBridge::isExtendRegistered() {
	bool registered = false;

	OleInitialize(NULL);
	CLSID clsid;
	if (CLSIDFromProgID(L"Extend.Application", &clsid) == S_OK) {
		registered = true;
	}

	return registered;
}
Ejemplo n.º 28
0
STDMETHODIMP CScdSolver::CreateSpModel(BSTR ProgID, IScdTaggedObject **pModel)
  {
  dllSCD_COMENTRYGET(long, pModel)
    {
    CLSID clsid;
    if (SUCCEEDED(CLSIDFromProgID(ProgID, &clsid)))
      {
      return Scd.ReturnH(::CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IScdTaggedObject, (void**)pModel));
      };
    return Scd.ReturnH(E_FAIL);
    }
Ejemplo n.º 29
0
Reference *
Reference::getActiveObject (const char *progId)
{
    // Convert the Prog ID to a CLSID.
    CLSID clsid;
    HRESULT hr = CLSIDFromProgID(_bstr_t(progId), &clsid);
    if (FAILED(hr)) {
        _com_issue_error(hr);
    }

    return getActiveObject(clsid, 0);
}
Ejemplo n.º 30
0
BOOL CContainerDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	CLSID clsid;
	CLSIDFromProgID(L"WmTER32X.WSTer32XCtrl.1",&clsid);

	m_wndTerX.CreateControl(clsid, _T("TERX"),WS_VISIBLE|WS_CHILD, CRect(0,0,640,430),this,1001);	

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}