/********************************************************************** * register_namespace_extensions */ static WCHAR *get_namespace_key(struct regsvr_namespace const *list) { static const WCHAR wszExplorerKey[] = { 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\', 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', 'E','x','p','l','o','r','e','r','\\',0 }; static const WCHAR wszNamespace[] = { '\\','N','a','m','e','s','p','a','c','e','\\',0 }; WCHAR *pwszKey, *pwszCLSID; pwszKey = HeapAlloc(GetProcessHeap(), 0, sizeof(wszExplorerKey)+sizeof(wszNamespace)+ sizeof(WCHAR)*(lstrlenW(list->parent)+CHARS_IN_GUID)); if (!pwszKey) return NULL; lstrcpyW(pwszKey, wszExplorerKey); lstrcatW(pwszKey, list->parent); lstrcatW(pwszKey, wszNamespace); if (FAILED(StringFromCLSID(list->clsid, &pwszCLSID))) { HeapFree(GetProcessHeap(), 0, pwszKey); return NULL; } lstrcatW(pwszKey, pwszCLSID); CoTaskMemFree(pwszCLSID); return pwszKey; }
void GUID2String(GUID *guid, LPOLESTR *str) { if (guid && str) { CLSID clsid = *guid; StringFromCLSID(clsid, str); } }
tstring GUIDToStr(GUID clsid) { LPOLESTR str = NULL; StringFromCLSID(clsid, &str); tstring ret(str); CoTaskMemFree(str); return ret; }
VOID InitializePropertyDialog( LANSTATUSUI_CONTEXT * pContext, NETCON_PROPERTIES * pProperties) { DWORD dwSize, dwAdapterIndex, dwResult; LPOLESTR pStr; IP_ADAPTER_INFO *pAdapterInfo, *pCurAdapter; if (FAILED(StringFromCLSID((CLSID)pProperties->guidId, &pStr))) { return; } /* get the IfTable */ dwSize = 0; dwResult = GetAdaptersInfo(NULL, &dwSize); if (dwResult!= ERROR_BUFFER_OVERFLOW) { CoTaskMemFree(pStr); return; } pAdapterInfo = static_cast<PIP_ADAPTER_INFO>(CoTaskMemAlloc(dwSize)); if (!pAdapterInfo) { CoTaskMemFree(pAdapterInfo); CoTaskMemFree(pStr); return; } if (GetAdaptersInfo(pAdapterInfo, &dwSize) != NO_ERROR) { CoTaskMemFree(pAdapterInfo); CoTaskMemFree(pStr); return; } if (!GetAdapterIndexFromNetCfgInstanceId(pAdapterInfo, pStr, &dwAdapterIndex)) { CoTaskMemFree(pAdapterInfo); CoTaskMemFree(pStr); return; } pCurAdapter = pAdapterInfo; while (pCurAdapter->Index != dwAdapterIndex) pCurAdapter = pCurAdapter->Next; pContext->IpAddress = inet_addr(pCurAdapter->IpAddressList.IpAddress.String); pContext->SubnetMask = inet_addr(pCurAdapter->IpAddressList.IpMask.String); pContext->Gateway = inet_addr(pCurAdapter->GatewayList.IpAddress.String); pContext->DHCPEnabled = pCurAdapter->DhcpEnabled; CoTaskMemFree(pStr); CoTaskMemFree(pAdapterInfo); pContext->dwAdapterIndex = dwAdapterIndex; }
HRESULT CCoordTransService::FindCTF (void) { USES_CONVERSION; char cbCTFName[_MAX_PATH]; CComBSTR bstr (GetProperty (m_Props, g_cbCoordTransform, A2OLE(g_cbDefault))); strcpy (cbCTFName, OLE2A(bstr)); if (!stricmp (cbCTFName, g_cbDefault)) m_fIsDefault = true; // CTFService's über CATID enumerieren, CTFService wiederfinden try { WEnumGUID EnumGuids; // Enumerator der CTFService-Objekte WCatInformation CatInfo (CLSID_StdComponentCategoriesMgr); // throws hr GUID guidImpl[1]; guidImpl[0] = CATID_TRiASCoordsystem; THROW_FAILED_HRESULT(CatInfo -> EnumClassesOfCategories (1, guidImpl, 0, NULL, EnumGuids.ppi())); GUID guid; LPOLESTR lpGuid = NULL; bool fFoundGuid = false; for (EnumGuids -> Reset(); S_OK == EnumGuids -> Next (1, &guid, NULL); /**/) { THROW_FAILED_HRESULT(StringFromCLSID (guid, &lpGuid)); CClassesRoot regClsID (OLE2A(lpGuid)); char cbBuffer[_MAX_PATH]; LONG lSize = sizeof(cbBuffer); if (NULL != lpGuid) { CoTaskMemFree (lpGuid); lpGuid = NULL; } if (regClsID.isValid() && regClsID.GetSZ (g_cbOldName, cbBuffer, lSize)) { if (!stricmp (cbBuffer, cbCTFName)) { fFoundGuid = true; m_strCTF = cbBuffer; break; } } } if (!fFoundGuid) { TX_ASSERT(fFoundGuid); return E_FAIL; // snh! } } catch (_com_error &e) { TX_ASSERT(S_OK == _COM_ERROR(e)); return _COM_ERROR(e); } return S_OK; }
HRESULT PrintTInfo(ITypeInfo* pTinfo, int indentation){ TYPEATTR* pTypeAttr; HRESULT hr = pTinfo->GetTypeAttr(&pTypeAttr); COMRet(hr); for(int inden = 0; inden != indentation; ++inden) std::wcout<<TEXT(" "); LPOLESTR guid_str; hr = StringFromCLSID(pTypeAttr->guid, &guid_str); std::wcout<<guid_str<<std::endl; // Inherited Interfaces, therefore we recursively call PrintInfo for(int i = 0; i != pTypeAttr->cImplTypes; ++i){ HREFTYPE RefType; hr = pTinfo->GetRefTypeOfImplType(i, &RefType); COMRet(hr); ITypeInfo* pImplTinfo; hr = pTinfo->GetRefTypeInfo(RefType, &pImplTinfo); COMRet(hr); hr = PrintTInfo(pImplTinfo, indentation + 1); if(hr != S_OK && hr != TYPE_E_BADMODULEKIND) return hr; // Because this ITypeInfo is retrieved pImplTinfo->Release(); // directly from a .tlb file instead // of a .dll, AddressofMember fails } //member functions for(int i = 0; i != pTypeAttr->cFuncs; ++i){ FUNCDESC* pFuncDesc; hr = pTinfo->GetFuncDesc(i, &pFuncDesc); COMRet(hr); const UINT cMaxNames = 10; UINT cNames; BSTR rgBstrNames[cMaxNames]; hr = pTinfo->GetNames(pFuncDesc->memid, rgBstrNames, cMaxNames, &cNames); COMRet(hr); void* pv; hr = pTinfo->AddressOfMember(pFuncDesc->memid, pFuncDesc->invkind, &pv); if(hr != S_OK && hr != TYPE_E_BADMODULEKIND) return hr; for(int inden = 0; inden != indentation; ++inden) std::wcout<<TEXT(" "); std::wcout<<TEXT("Func memid = ")<<pFuncDesc->memid<<TEXT(" Name = ")<<*rgBstrNames<<TEXT(" DllAddress = ")<<pv<<std::endl; for(int j = 0; j != pFuncDesc->cParams; ++j){ TCHAR szBuffer[30]; wParamFlagsTranslate(pFuncDesc->lprgelemdescParam->paramdesc.wParamFlags, szBuffer, 30); for(int inden = 0; inden != indentation; ++inden) std::wcout<<TEXT(" "); std::wcout<<TEXT(" ")<<szBuffer<<TEXT(" ")<<*(rgBstrNames+j+1)<<TEXT(": ")<<std::endl; TExpandPointer(pFuncDesc->lprgelemdescParam->tdesc, 2); } pTinfo->ReleaseFuncDesc(pFuncDesc); } //member variables for(int i = 0; i != pTypeAttr->cVars; ++i){ VARDESC* pVarDesc; hr = pTinfo->GetVarDesc(i, &pVarDesc); COMRet(hr); for(int inden = 0; inden != indentation; ++inden) std::wcout<<TEXT(" "); std::wcout<<TEXT("Var memid = ")<<pVarDesc->memid<<TEXT("Varkind = ")<<pVarDesc->varkind<<std::endl; TCHAR szBuffer[30]; wParamFlagsTranslate(pVarDesc->elemdescVar.paramdesc.wParamFlags, szBuffer, 30); for(int inden = 0; inden != indentation; ++inden) std::wcout<<TEXT(" "); std::wcout<<" Variable wParamFlags: "<<szBuffer<<std::endl; TExpandPointer(pVarDesc->elemdescVar.tdesc, 1); pTinfo->ReleaseVarDesc(pVarDesc); } pTinfo->ReleaseTypeAttr(pTypeAttr); return hr; }
HRESULT WpdObjectResources::CreateResourceContext( _In_ ContextMap* pContextMap, _In_ LPCWSTR pszObjectID, _In_ REFPROPERTYKEY ResourceKey, _In_ BOOL bCreateRequest, _Outptr_ LPWSTR* ppszResourceContext) { HRESULT hr = S_OK; GUID guidContext = GUID_NULL; ResourceContext* pContext = NULL; if((pContextMap == NULL) || (pszObjectID == NULL) || (ppszResourceContext == NULL)) { hr = E_POINTER; CHECK_HR(hr, "Cannot have NULL parameter"); return hr; } *ppszResourceContext = NULL; hr = CoCreateGuid(&guidContext); CHECK_HR(hr, "Failed to CoCreateGuid used for identifying the resource context"); if (SUCCEEDED(hr)) { pContext = new ResourceContext(); if(pContext == NULL) { hr = E_OUTOFMEMORY; CHECK_HR(hr, "Failed to allocate new resource context"); } } if (SUCCEEDED(hr)) { pContext->ObjectID = pszObjectID; pContext->Key = ResourceKey; pContext->CreateRequest = bCreateRequest; CAtlStringW strKey = CComBSTR(guidContext); hr = pContextMap->Add(strKey, pContext); CHECK_HR(hr, "Failed to insert bulk property operation context into our context Map"); } if (SUCCEEDED(hr)) { hr = StringFromCLSID(guidContext, ppszResourceContext); CHECK_HR(hr, "Failed to allocate string from GUID for resource context"); } SAFE_RELEASE(pContext); return hr; }
////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// bstr_t GUIDGen() { GUID NewGuid; CoCreateGuid(&NewGuid); LPOLESTR strW; StringFromCLSID(NewGuid,&strW); CString str = strW; CoTaskMemFree((void*)strW); return str.Mid(1,36); }
void tCOMUtil::DumpTypeInfo(ITypeInfo *typeinfo) { HRESULT hr = S_OK; TYPEATTR* pta = NULL; CHECKPARAM(typeinfo); hr = typeinfo->GetTypeAttr(&pta); CHK_COM_CODE(hr); // prints IID LPOLESTR lpsz = NULL; #ifdef __WINE__ hr = 0; MessageBox(NULL, "FIX - not implemented - StringFromIID", "LuaCOM", MB_ICONEXCLAMATION); #warning FIX - not implemented - StringFromIID #else hr = StringFromIID(pta->guid, &lpsz); #endif if(FAILED(hr)) { hr = StringFromCLSID(pta->guid, &lpsz); } if(SUCCEEDED(hr)) { wprintf(L"\nInterface: %s\n\n", lpsz); CoTaskMemFree(lpsz); } int i = 0; FUNCDESC *pfd = NULL; for(i = 0; i < pta->cFuncs; i++) { typeinfo->GetFuncDesc(i, &pfd); BSTR names[1]; unsigned int dumb; typeinfo->GetNames(pfd->memid, names, 1, &dumb); printf("%.3d: %-30s\tid=0x%d\t%d param(s)\n", i, tUtil::bstr2string(names[0]), pfd->memid, pfd->cParams); typeinfo->ReleaseFuncDesc(pfd); SysFreeString(names[0]); } typeinfo->ReleaseTypeAttr(pta); }
static char *_php3_string_from_clsid(CLSID *clsid) { LPOLESTR s_clsid; char *clsid_str; StringFromCLSID(clsid, &s_clsid); clsid_str = _php3_unicode_to_C_str(s_clsid, NULL); LocalFree(s_clsid); return clsid_str; }
static std::wstring GetFsBoxCLSID() { LPOLESTR olestr_CLSID_FsBox = 0; if (FAILED(StringFromCLSID(CLSID_FsBox, &olestr_CLSID_FsBox))) { return L""; } std::wstring result(olestr_CLSID_FsBox, olestr_CLSID_FsBox + wcslen(olestr_CLSID_FsBox)); CoTaskMemFree(olestr_CLSID_FsBox); return result; }
static char *php_com_string_from_clsid(const CLSID *clsid, int codepage) { LPOLESTR ole_clsid; char *clsid_str; StringFromCLSID(clsid, &ole_clsid); clsid_str = php_com_olestring_to_string(ole_clsid, NULL, codepage); LocalFree(ole_clsid); return clsid_str; }
static int check_wave_format(Xcap_wasapi_param *wparam) { WAVEFORMATEX *pwfx = wparam->pwfx; WAVEFORMATEXTENSIBLE *ext = (WAVEFORMATEXTENSIBLE*) wparam->pwfx; // if(pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) { if(ext->SubFormat == KSDATAFORMAT_SUBTYPE_IEEE_FLOAT) { wparam->isFloat = 1; } else if(ext->SubFormat != KSDATAFORMAT_SUBTYPE_PCM) { OLECHAR *guidstr; char *in, *out, guid2[256]; StringFromCLSID(ext->SubFormat, &guidstr); // because GUID is UTF-16LE? for(in = (char*) guidstr, out = guid2; *in; in += 2) { *out++ = *in; } *out = '\0'; // ga_error("WAVEFORMATEXTENSIBLE: non-PCM is not supported (Format GUID=%s)\n", guid2); CoTaskMemFree(guidstr); return -1; } } else if(pwfx->wFormatTag != WAVE_FORMAT_PCM) { ga_error("WAVEFORMATEX: non-PCM is not supported\n"); return -1; } if(pwfx->nChannels != 2) { ga_error("WAVEFORMATEX: channels = %d (!=2)\n", pwfx->nChannels); return -1; } ga_error("WAVEFORMATEX: samplerate=%d, bitspersample=%d\n", pwfx->nSamplesPerSec, pwfx->wBitsPerSample); // if(wparam->samplerate != pwfx->nSamplesPerSec) { ga_error("WAVEFORMATEX: audio sample rate mismatch (%d != %d)\n", wparam->samplerate, pwfx->nSamplesPerSec); return -1; } // if(wparam->isFloat) { if(wparam->bits_per_sample != 16) { ga_error("WAVEFORMATEX: [float] audio bits per sample mismatch (%d != 16)\n", wparam->bits_per_sample); } } else if(wparam->bits_per_sample != pwfx->wBitsPerSample) { ga_error("WAVEFORMATEX: audio bits per sample mismatch (%d != %d)\n", wparam->bits_per_sample, pwfx->wBitsPerSample); return -1; } return 0; }
static void CLSIDToString( const CLSID& clsid, char* pszCLSID, int cb ) { LPOLESTR pwszCLSID; if (SUCCEEDED( StringFromCLSID( clsid, &pwszCLSID ) )) { // Covert from wide characters to non-wide. wcstombs( pszCLSID, pwszCLSID, cb ); // Free memory. CoTaskMemFree( pwszCLSID ); } }
void CAboutDlg::FillObjectVersion(CLSID clsid) { LPOLESTR szCLSID=NULL; StringFromCLSID (clsid, &szCLSID); CString strKey = _T("CLSID\\"); strKey += CString (szCLSID); CoTaskMemFree (szCLSID); CRegKey key; long lResult = key.Open(HKEY_CLASSES_ROOT, strKey , KEY_READ ); if (lResult == ERROR_SUCCESS) { CEgRegKey keyModule; long lResult = keyModule.Open( key, _T("LocalServer32"), KEY_READ ); if (lResult != ERROR_SUCCESS) lResult = keyModule.Open( key, _T("InprocServer32"), KEY_READ ); if (lResult == ERROR_SUCCESS) { CString strVal; //LPTSTR szVal = strVal.GetBuffer(MAX_PATH); //DWORD dwSize = MAX_PATH; keyModule.QueryValue (strVal, _T("")); strVal.ReleaseBuffer(); if (!strVal.IsEmpty() ) { CModuleVersion ver; CString strVer = _T("N/A"); if (ver.GetFileVersionInfo (strVal)) ver.GetValue(_T("FileVersion"), strVer); WIN32_FIND_DATA data; HANDLE hFind = FindFirstFile (strVal, &data); if( hFind != INVALID_HANDLE_VALUE ) { FindClose(hFind); CString strFmt; strFmt.Format (_T("%s\t%s"), data.cFileName, (LPCTSTR) strVer); AddInfoStr (strFmt); } } } key.Close(); } }
String guidToString(const GUID &guid) { LPOLESTR resStr; String res; if (StringFromCLSID(guid, &resStr) == S_OK) { res = resStr; CoTaskMemFree(resStr); } return res; }
STDMETHODIMP CThisTestModule::GetCLSID(BSTR* pGUID) { TRACE("CThisTestModule::GetCLSID\n"); if(pGUID == NULL) return E_INVALIDARG; WCHAR* pwszClsid = NULL; StringFromCLSID(*(m_gmd.m_pguidModuleCLSID), &pwszClsid); *pGUID = SysAllocString(pwszClsid); SAFE_FREE(pwszClsid); return S_OK; }
KString KCLSIDToString(REFCLSID rCLSID) { LPOLESTR pBuf = NULL; if(StringFromCLSID(rCLSID, &pBuf)) return WRONG_CLSID_TEXT; TDefaultString Ret = pBuf; CoTaskMemFree(pBuf); return (LPCTSTR)Ret; }
KSDDKAPI HRESULT WINAPI DllUnregisterServer(void) { ULONG Index = 0; LPOLESTR pStr; HRESULT hr = S_OK; HKEY hClass; hr = StringFromCLSID(KSCATEGORY_BDA_NETWORK_PROVIDER, &pStr); if (FAILED(hr)) return hr; if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_SET_VALUE, &hClass) != ERROR_SUCCESS) { CoTaskMemFree(pStr); return E_FAIL; } RegDeleteKeyW(hClass, pStr); CoTaskMemFree(pStr); do { hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr); if (FAILED(hr)) break; RegDeleteKeyW(hClass, pStr); CoTaskMemFree(pStr); Index++; }while(InterfaceTable[Index].lpfnCI != 0); RegCloseKey(hClass); return hr; }
void CAddInRegistrar::Unregister(CLSID clsid) { LPOLESTR lpClsidString; StringFromCLSID(clsid, &lpClsidString); CString strKeyCLSID = lpClsidString; CRegKey key; key.Open(HKEY_CLASSES_ROOT, L"CLSID"); key.RecurseDeleteKey(strKeyCLSID); key.Close(); CoTaskMemFree(lpClsidString); }
// Convert a CLSID to a char string. void CLSIDtochar(REFCLSID clsid, char* szCLSID, int length) { assert(length >= CLSID_STRING_SIZE); // Get CLSID LPOLESTR wszCLSID = NULL; HRESULT hr = StringFromCLSID(clsid, &wszCLSID); assert(SUCCEEDED(hr)); // Covert from wide characters to non-wide. wcstombs(szCLSID, wszCLSID, length); // Free memory. CoTaskMemFree(wszCLSID); }
int main (int argc, char* argv[]) { if (argc != 2) { fprintf (stderr, "SYNTAX: UUIDGEN <number-of-GUIDs-to-generate>\n"); return 1; } count = atoi (argv[1]); for (i = 0; i < count; i++) { CoCreateGuid (&guid); StringFromCLSID (guid, wstrGUID); WideCharToMultiByte (CP_ACP, 0, *wstrGUID, -1, strGUID, MAX_PATH, NULL, NULL); printf ("%s\n", strGUID); } return 0; }
HRESULT STDMETHODCALLTYPE adpbho::QueryInterface( REFIID riid, //Identifier of the requested interface void ** ppvObject //Address of output variable that receives the //interface pointer requested in iid ) { MB1("adpbho: QueryInterface"); /* adpbho: neither IID_IUnknown nor clsid_extie, {34A715A0-6587-11D0-924A-0020AFC7AC4D} DIID_DWebBrowserEvents2 adpbho: neither IID_IUnknown nor clsid_extie, {49C3DE7C-D329-11D0-AB73-00C04FC33E80} */ if ( riid == IID_IUnknown ) { *ppvObject = static_cast<adpbho*> (this); } else if (riid == IID_IObjectWithSite) { // ::MessageBox(0, "Querying for IID_IObjectWithSite", 0, 0); *ppvObject = static_cast<IObjectWithSite*>(this); //::MessageBox(0,"XXXXXXXXXXXXXXXXXXXX", 0, 0); //char buf[50]; //sprintf(buf, "%x", ppvObject //static_cast<IObjectWithSite*>(*ppvObject)->SetSite(0); } else if (riid == IID_IDispatch) { // ::MessageBox(0, "Querying for IID_IDispatch", 0, 0); *ppvObject = static_cast<IDispatch*>(this); //unsigned int* x=new unsigned(4); //static_cast<IDispatch*>(this)->GetTypeInfoCount(x); //::MessageBox(0,"its an GotType", 0, 0); } else { // Information on StringFromCLSID can be found here: // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/cmf_a2c_05r8.asp wchar_t* buf; StringFromCLSID(riid, &buf); wchar_t buf1[150]; wsprintfW(buf1, L"adpbho: neither IID_IUnknown nor clsid_extie, %s", buf); ::CoTaskMemFree(buf); // ::MessageBoxW(0, buf1, 0, 0); *ppvObject = 0; return E_NOINTERFACE; } AddRef(); return S_OK; }
void DumpIID(REFIID iid, LPCTSTR pszClassName) { USES_CONVERSION; CRegKey key; TCHAR szName[100]; DWORD dwType; DWORD dw = sizeof(szName); LPOLESTR pszGUID = NULL; if (FAILED(StringFromCLSID(iid, &pszGUID))) return; OutputDebugString(pszClassName); OutputDebugString(_T(" - ")); bool bFound = false; // Attempt to find it in the interfaces section if (key.Open(HKEY_CLASSES_ROOT, _T("Interface"), KEY_READ) == ERROR_SUCCESS) { if (key.Open(key, OLE2T(pszGUID), KEY_READ) == ERROR_SUCCESS) { *szName = 0; if (RegQueryValueEx(key.m_hKey, (LPTSTR)NULL, NULL, &dwType, (LPBYTE)szName, &dw) == ERROR_SUCCESS) { OutputDebugString(szName); bFound = true; } } } // Attempt to find it in the clsid section else if (key.Open(HKEY_CLASSES_ROOT, _T("CLSID"), KEY_READ) == ERROR_SUCCESS) { if (key.Open(key, OLE2T(pszGUID), KEY_READ) == ERROR_SUCCESS) { *szName = 0; if (RegQueryValueEx(key.m_hKey, (LPTSTR)NULL, NULL, &dwType, (LPBYTE)szName, &dw) == ERROR_SUCCESS) { OutputDebugString(_T("(CLSID\?\?\?) ")); OutputDebugString(szName); bFound = true; } } } if (!bFound) OutputDebugString(OLE2T(pszGUID)); OutputDebugString(_T("\n")); CoTaskMemFree(pszGUID); }
void DbgPrintGUID(REFIID riid) { OLECHAR* pguid; TCHAR Guid[MAX_PATH]; TCHAR Buffer[MAX_PATH]; TCHAR Subkey[MAX_PATH]; TCHAR Subkey2[MAX_PATH]; // DWORD TypeStr = REG_SZ; LONG uKeyLenght; StringFromCLSID(riid, &pguid); wsprintf(Guid, "%S", pguid); CoTaskMemFree(pguid); uKeyLenght = sizeof(Buffer); wsprintf(Subkey, "CLSID\\%s", Guid); if (RegQueryValue(HKEY_CLASSES_ROOT, Subkey, Buffer, &uKeyLenght) == ERROR_SUCCESS) { OutputDebugString(Buffer); return; } uKeyLenght = sizeof(Buffer); wsprintf(Subkey2, "Interface\\%s", Guid); if (RegQueryValue(HKEY_CLASSES_ROOT, Subkey2, Buffer, &uKeyLenght) == ERROR_SUCCESS) { OutputDebugString(Buffer); return; } uKeyLenght = sizeof(Buffer); wsprintf(Subkey2, "Filter\\%s", Guid); if (RegQueryValue(HKEY_CLASSES_ROOT, Subkey2, Buffer, &uKeyLenght) == ERROR_SUCCESS) { OutputDebugString(Buffer); return; } uKeyLenght = sizeof(Buffer); wsprintf(Subkey2, "TypeLib\\%s", Guid); if (RegQueryValue(HKEY_CLASSES_ROOT, Subkey2, Buffer, &uKeyLenght) == ERROR_SUCCESS) { OutputDebugString(Buffer); return; } OutputDebugString(Guid); return; }
HRESULT primGUIDToString( CLSID* guid, WCHAR** guidStr ) { CLSID* rclsid; HRESULT hr; rclsid = (CLSID*)guid; if (!rclsid) rclsid = (CLSID*)&IID_NULL; if (guidStr) { hr = StringFromCLSID( rclsid, guidStr ); } else { hr = E_POINTER; } return hr; }
/*--------------------------------------------------------------------------*/ wchar_t *createGUID(void) { GUID guid; wchar_t* pwstrGUID = NULL; wchar_t* ret = NULL; CoCreateGuid (&guid); StringFromCLSID(&guid, &pwstrGUID); //remove first '{' and last '}' pwstrGUID[wcslen(pwstrGUID) - 1] = L'\0'; ret = os_wcsdup(pwstrGUID + 1); CoTaskMemFree(pwstrGUID); return ret; }
void tCOMUtil::DumpTypeInfo(ITypeInfo *typeinfo) { HRESULT hr = S_OK; TYPEATTR* pta = NULL; CHECKPARAM(typeinfo); hr = typeinfo->GetTypeAttr(&pta); CHK_COM_CODE(hr); // prints IID LPOLESTR lpsz = NULL; hr = StringFromIID(pta->guid, &lpsz); if(FAILED(hr)) { hr = StringFromCLSID(pta->guid, &lpsz); } if(SUCCEEDED(hr)) { wprintf(L"\nInterface: %s\n\n", lpsz); CoTaskMemFree(lpsz); } int i = 0; FUNCDESC *pfd = NULL; for(i = 0; i < pta->cFuncs; i++) { typeinfo->GetFuncDesc(i, &pfd); BSTR names[1]; unsigned int dumb; typeinfo->GetNames(pfd->memid, names, 1, &dumb); printf("%.3d: %-30s\tid=0x%p\t%d param(s)\n", i, tUtil::bstr2string(names[0]), pfd->memid, pfd->cParams); typeinfo->ReleaseFuncDesc(pfd); SysFreeString(names[0]); } typeinfo->ReleaseTypeAttr(pta); }
void _ATL_OBJMAP_ENTRY::UpdateRegistry(HINSTANCE hInst, HINSTANCE hInstResource) { USES_CONVERSION; TCHAR szDesc[256]; BOOL fStringLoaded = LoadString(hInstResource, nDescID, szDesc, 256); TCHAR szModule[_MAX_PATH]; GetModuleFileName(hInst, szModule, _MAX_PATH); LPOLESTR lpOleStr; StringFromCLSID(*pclsid, &lpOleStr); LPTSTR lpsz = OLE2T(lpOleStr); if (lpszProgID) AtlRegisterProgID(lpsz, lpszProgID, szDesc); if (lpszVerIndProgID) AtlRegisterProgID(lpsz, lpszVerIndProgID, szDesc); // // Would be best if the following checked for errors, but // at least we won't crap out any more 'cause CRegKey now // checks for correct internal state // -rga // CRegKey key; key.Open(HKEY_CLASSES_ROOT, szCLSID); key.Create(key, lpsz); if (dwFlags & CONTROLFLAG) { CRegKey x; x.Create(key, _T("Control")); } if (fStringLoaded) key.SetValue(szDesc); if (lpszProgID) key.SetKeyValue(szProgID, lpszProgID); if (lpszVerIndProgID) key.SetKeyValue(szVIProgID, lpszVerIndProgID); if ((hInst == NULL) || (hInst == GetModuleHandle(NULL))) // register as EXE key.SetKeyValue(szLS32, szModule); else key.SetKeyValue(szIPS32, (dwFlags & AUTPRXFLAG) ? szAUTPRX32:szModule); DWORD dwThreadFlags = dwFlags & 3; if (dwThreadFlags == THREADFLAGS_APARTMENT) key.SetKeyValue(szIPS32, szApartment, szThreadingModel); else if (dwThreadFlags == THREADFLAGS_BOTH) key.SetKeyValue(szIPS32, szBoth, szThreadingModel); CoTaskMemFree(lpOleStr); }
static BOOL CALLBACK DSoundEnumCaptureDevices(LPGUID guid, LPCSTR desc, LPCSTR drvname, LPVOID data) { LPOLESTR guidstr = NULL; char str[1024]; HRESULT hr; void *temp; int count; ALuint i; (void)data; (void)drvname; if(!guid) return TRUE; count = 0; do { if(count == 0) snprintf(str, sizeof(str), "%s", desc); else snprintf(str, sizeof(str), "%s #%d", desc, count+1); count++; for(i = 0;i < NumCaptureDevices;i++) { if(strcmp(str, CaptureDeviceList[i].name) == 0) break; } } while(i != NumCaptureDevices); hr = StringFromCLSID(guid, &guidstr); if(SUCCEEDED(hr)) { TRACE("Got device \"%s\", GUID \"%ls\"\n", str, guidstr); CoTaskMemFree(guidstr); } temp = realloc(CaptureDeviceList, sizeof(DevMap) * (NumCaptureDevices+1)); if(temp) { CaptureDeviceList = temp; CaptureDeviceList[NumCaptureDevices].name = strdup(str); CaptureDeviceList[NumCaptureDevices].guid = *guid; NumCaptureDevices++; } return TRUE; }