本文整理汇总了C++中StringFromGUID2函数的典型用法代码示例。如果您正苦于以下问题:C++ StringFromGUID2函数的具体用法?C++ StringFromGUID2怎么用?C++ StringFromGUID2使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StringFromGUID2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EnumDMO
void EnumDMO(bool bEnc)
{
char buf[256];
WCHAR wbuf[256];
WCHAR *pwsz;
IEnumDMO *pEnumDMO;
CLSID clsid;
DWORD dwCount;
DMOEnum(bEnc ? DMOCATEGORY_VIDEO_ENCODER : DMOCATEGORY_VIDEO_DECODER, DMO_ENUMF_INCLUDE_KEYED, 0, NULL, 0, NULL, &pEnumDMO);
while (pEnumDMO->Next(1, &clsid, &pwsz, &dwCount) == S_OK)
{
StringFromGUID2(clsid, wbuf, _countof(wbuf));
wsprintf(buf, "DMO\t%d\t%S\t%S\n", bEnc, pwsz, wbuf);
printf("%s", buf);
CoTaskMemFree(pwsz);
}
pEnumDMO->Release();
}
示例2: RegisterInprocServer
//
// 函数名称: RegisterInprocServer
//
// 作用: 在注册表中注册进程内组件
//
// 参数:
// * pszModule -包含该组件模块的路径
// * clsid -组件的类ID
// * pszFriendlyName -友元名称
// * pszThreadModel -线程模型
//
//
// 注意: 该方法在注册表中创建了HKCR\CLSID\{<CLSID>}注册项.
//
// HKCR
// {
// NoRemove CLSID
// {
// ForceRemove {<CLSID>} = s '<Friendly Name>'
// {
// InprocServer32 = s '%MODULE%'
// {
// val ThreadingModel = s '<Thread Model>'
// }
// }
// }
// }
//
HRESULT RegisterInprocServer(PCWSTR pszModule, const CLSID& clsid,
PCWSTR pszFriendlyName, PCWSTR pszThreadModel)
{
if (pszModule == NULL || pszThreadModel == NULL)
{
return E_INVALIDARG;
}
HRESULT hr;
wchar_t szCLSID[MAX_PATH];
StringFromGUID2(clsid, szCLSID, ARRAYSIZE(szCLSID));
wchar_t szSubkey[MAX_PATH];
// 创建 HKCR\CLSID\{<CLSID>}注册项.
hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey), L"CLSID\\%s", szCLSID);
if (SUCCEEDED(hr))
{
hr = SetHKCRRegistryKeyAndValue(szSubkey, NULL, pszFriendlyName);
//创建 HKCR\CLSID\{<CLSID>}\InprocServer32注册项.
if (SUCCEEDED(hr))
{
hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey),
L"CLSID\\%s\\InprocServer32", szCLSID);
if (SUCCEEDED(hr))
{
//以InprocServer32注册项的值作为为COM模块的路径的默认值
hr = SetHKCRRegistryKeyAndValue(szSubkey, NULL, pszModule);
if (SUCCEEDED(hr))
{
//为组件设置线程模型.
hr = SetHKCRRegistryKeyAndValue(szSubkey,
L"ThreadingModel", pszThreadModel);
}
}
}
}
return hr;
}
示例3: COMCAT_ICatInformation_IsClassOfCategories
/**********************************************************************
* COMCAT_ICatInformation_IsClassOfCategories
*/
static HRESULT WINAPI COMCAT_ICatInformation_IsClassOfCategories(
LPCATINFORMATION iface,
REFCLSID rclsid,
ULONG cImplemented,
CATID *rgcatidImpl,
ULONG cRequired,
CATID *rgcatidReq)
{
WCHAR keyname[45] = { 'C', 'L', 'S', 'I', 'D', '\\', 0 };
HRESULT res;
struct class_categories *categories;
HKEY key;
if (TRACE_ON(ole)) {
ULONG count;
TRACE("CLSID: %s Implemented %u\n",debugstr_guid(rclsid),cImplemented);
for (count = 0; count < cImplemented; ++count)
TRACE(" %s\n",debugstr_guid(&rgcatidImpl[count]));
TRACE("Required %u\n",cRequired);
for (count = 0; count < cRequired; ++count)
TRACE(" %s\n",debugstr_guid(&rgcatidReq[count]));
}
if ((cImplemented && rgcatidImpl == NULL) ||
(cRequired && rgcatidReq == NULL)) return E_POINTER;
res = StringFromGUID2(rclsid, keyname + 6, CHARS_IN_GUID);
if (FAILED(res)) return res;
categories = COMCAT_PrepareClassCategories(cImplemented, rgcatidImpl,
cRequired, rgcatidReq);
if (categories == NULL) return E_OUTOFMEMORY;
res = open_classes_key(HKEY_CLASSES_ROOT, keyname, KEY_READ, &key);
if (res == ERROR_SUCCESS) {
res = COMCAT_IsClassOfCategories(key, categories);
RegCloseKey(key);
} else res = S_FALSE;
HeapFree(GetProcessHeap(), 0, categories);
return res;
}
示例4: szUsername
JobbedProcessManager::JobbedProcessManager() :
szUsername(nullptr), szPassword(nullptr), szDirectory(nullptr), szCmdLine(nullptr),
szExecutable(nullptr), szEnvBlock(nullptr),
tle_(false), mle_(false), terminate_shocker(false) {
ZeroMemory(&extLimits, sizeof extLimits);
extLimits.BasicLimitInformation.ActiveProcessLimit = 1;
extLimits.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_ACTIVE_PROCESS;
ZeroMemory(&uiLimits, sizeof uiLimits);
uiLimits.UIRestrictionsClass = JOB_OBJECT_UILIMIT_DESKTOP |
JOB_OBJECT_UILIMIT_DISPLAYSETTINGS |
JOB_OBJECT_UILIMIT_EXITWINDOWS |
JOB_OBJECT_UILIMIT_GLOBALATOMS |
JOB_OBJECT_UILIMIT_HANDLES |
JOB_OBJECT_UILIMIT_READCLIPBOARD |
JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS |
JOB_OBJECT_UILIMIT_WRITECLIPBOARD;
CoCreateGuid(&guid);
StringFromGUID2(guid, szGuid, ARRAYSIZE(szGuid));
}
示例5: COMCAT_ICatRegister_RegisterCategories
/**********************************************************************
* COMCAT_ICatRegister_RegisterCategories
*/
static HRESULT WINAPI COMCAT_ICatRegister_RegisterCategories(
LPCATREGISTER iface,
ULONG cCategories,
CATEGORYINFO *rgci)
{
HKEY comcat_key;
HRESULT res;
TRACE("\n");
if (cCategories && rgci == NULL)
return E_POINTER;
/* Create (or open) the component categories key. */
res = RegCreateKeyExW(HKEY_CLASSES_ROOT, comcat_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &comcat_key, NULL);
if (res != ERROR_SUCCESS) return E_FAIL;
for (; cCategories; --cCategories, ++rgci) {
static const WCHAR fmt[] = { '%', 'l', 'X', 0 };
WCHAR keyname[39];
WCHAR valname[9];
HKEY cat_key;
/* Create (or open) the key for this category. */
if (!StringFromGUID2(&rgci->catid, keyname, 39)) continue;
res = RegCreateKeyExW(comcat_key, keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &cat_key, NULL);
if (res != ERROR_SUCCESS) continue;
/* Set the value for this locale's description. */
wsprintfW(valname, fmt, rgci->lcid);
RegSetValueExW(cat_key, valname, 0, REG_SZ,
(CONST BYTE*)(rgci->szDescription),
(lstrlenW(rgci->szDescription) + 1) * sizeof(WCHAR));
RegCloseKey(cat_key);
}
RegCloseKey(comcat_key);
return S_OK;
}
示例6: MediaStreamFilterImpl_AddMediaStream
static HRESULT WINAPI MediaStreamFilterImpl_AddMediaStream(IMediaStreamFilter* iface, IAMMediaStream *pAMMediaStream)
{
IMediaStreamFilterImpl *This = impl_from_IMediaStreamFilter(iface);
IMediaStream** streams;
IPin** pins;
MediaStreamFilter_InputPin* pin;
HRESULT hr;
PIN_INFO info;
MSPID purpose_id;
TRACE("(%p)->(%p)\n", iface, pAMMediaStream);
streams = CoTaskMemRealloc(This->streams, (This->nb_streams + 1) * sizeof(IMediaStream*));
if (!streams)
return E_OUTOFMEMORY;
This->streams = streams;
pins = CoTaskMemRealloc(This->pins, (This->nb_streams + 1) * sizeof(IPin*));
if (!pins)
return E_OUTOFMEMORY;
This->pins = pins;
info.pFilter = (IBaseFilter*)&This->filter;
info.dir = PINDIR_INPUT;
hr = IAMMediaStream_GetInformation(pAMMediaStream, &purpose_id, NULL);
if (FAILED(hr))
return hr;
/* Pin name is "I{guid MSPID_PrimaryVideo or MSPID_PrimaryAudio}" */
info.achName[0] = 'I';
StringFromGUID2(&purpose_id, info.achName + 1, 40);
hr = BaseInputPin_Construct(&MediaStreamFilter_InputPin_Vtbl, sizeof(BaseInputPin), &info, &input_BaseFuncTable,
&input_BaseInputFuncTable, &This->filter.csFilter, NULL, &This->pins[This->nb_streams]);
if (FAILED(hr))
return hr;
pin = (MediaStreamFilter_InputPin*)This->pins[This->nb_streams];
pin->pin.pin.pinInfo.pFilter = (LPVOID)This;
This->streams[This->nb_streams] = (IMediaStream*)pAMMediaStream;
This->nb_streams++;
IMediaStream_AddRef((IMediaStream*)pAMMediaStream);
return S_OK;
}
示例7: UnregisterShellExtContextMenuHandler
//
// FUNCTION: UnregisterShellExtContextMenuHandler
//
// PURPOSE: Unregister the context menu handler.
//
// PARAMETERS:
// * pszFileType - The file type that the context menu handler is
// associated with. For example, '*' means all file types; '.txt' means
// all .txt files. The parameter must not be NULL.
// * clsid - Class ID of the component
//
// NOTE: The function removes the {<CLSID>} key under
// HKCR\<File Type>\shellex\ContextMenuHandlers in the registry.
//
HRESULT UnregisterShellExtContextMenuHandler(
PCWSTR pszFileType, const CLSID& clsid)
{
if (pszFileType == NULL)
{
return E_INVALIDARG;
}
HRESULT hr;
wchar_t szCLSID[MAX_PATH];
StringFromGUID2(clsid, szCLSID, ARRAYSIZE(szCLSID));
wchar_t szSubkey[MAX_PATH];
// If pszFileType starts with '.', try to read the default value of the
// HKCR\<File Type> key which contains the ProgID to which the file type
// is linked.
if (*pszFileType == L'.')
{
wchar_t szDefaultVal[260];
hr = GetHKCRRegistryKeyAndValue(pszFileType, NULL, szDefaultVal,
sizeof(szDefaultVal));
// If the key exists and its default value is not empty, use the
// ProgID as the file type.
if (SUCCEEDED(hr) && szDefaultVal[0] != L'\0')
{
pszFileType = szDefaultVal;
}
}
// Remove the HKCR\<File Type>\shellex\ContextMenuHandlers\{<CLSID>} key.
hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey),
L"%s\\shellex\\ContextMenuHandlers\\%s", pszFileType, szCLSID);
if (SUCCEEDED(hr))
{
hr = HRESULT_FROM_WIN32(RegDeleteTree(HKEY_CLASSES_ROOT, szSubkey));
}
return hr;
}
示例8: StringFromGUID2
HRESULT OCContextMenuRegHandler::RegisterInprocServer(PCWSTR pszModule, const CLSID& clsid, PCWSTR pszFriendlyName, PCWSTR pszThreadModel)
{
if (pszModule == NULL || pszThreadModel == NULL)
{
return E_INVALIDARG;
}
HRESULT hr;
wchar_t szCLSID[MAX_PATH];
StringFromGUID2(clsid, szCLSID, ARRAYSIZE(szCLSID));
wchar_t szSubkey[MAX_PATH];
// Create the HKCR\CLSID\{<CLSID>} key.
hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey), L"CLSID\\%s", szCLSID);
if (SUCCEEDED(hr))
{
hr = SetHKCRRegistryKeyAndValue(szSubkey, NULL, pszFriendlyName);
// Create the HKCR\CLSID\{<CLSID>}\InprocServer32 key.
if (SUCCEEDED(hr))
{
hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey),
L"CLSID\\%s\\InprocServer32", szCLSID);
if (SUCCEEDED(hr))
{
// Set the default value of the InprocServer32 key to the
// path of the COM module.
hr = SetHKCRRegistryKeyAndValue(szSubkey, NULL, pszModule);
if (SUCCEEDED(hr))
{
// Set the threading model of the component.
hr = SetHKCRRegistryKeyAndValue(szSubkey,
L"ThreadingModel", pszThreadModel);
}
}
}
}
return hr;
}
示例9: StringFromGUID2
/* static private */
HRESULT REGUTIL::_RegisterClassBase( REFCLSID rclsid,
const char *szDesc,
const char *szProgID,
const char *szIndepProgID,
char *szOutCLSID )
{
char szID[64]; // the class ID to register.
OLECHAR szWID[64]; // helper for the class ID to register.
StringFromGUID2( rclsid, szWID, NumItems( szWID ) );
WideCharToMultiByte( CP_ACP,
0,
szWID,
-1,
szID,
sizeof( szID ),
NULL,
NULL );
strcpy( szOutCLSID, "CLSID\\" );
strcat( szOutCLSID, szID );
// create ProgID keys.
SetKeyAndValue( szProgID, NULL, szDesc );
SetKeyAndValue( szProgID, "CLSID", szID );
// create VersionIndependentProgID keys.
SetKeyAndValue( szIndepProgID, NULL, szDesc );
SetKeyAndValue( szIndepProgID, "CurVer", szProgID );
SetKeyAndValue( szIndepProgID, "CLSID", szID );
// create entries under CLSID.
SetKeyAndValue( szOutCLSID, NULL, szDesc );
SetKeyAndValue( szOutCLSID, "ProgID", szProgID );
SetKeyAndValue( szOutCLSID, "VersionIndependentProgID", szIndepProgID );
SetKeyAndValue( szOutCLSID, "NotInsertable", NULL );
return S_OK;
} // REGUTIL::_RegisterClassBase
示例10: defined
///////////////////////////////////////////////////////////
//
// Class factory body
//
HRESULT __stdcall IOemCF::QueryInterface(const IID& iid, void** ppv)
{
if ((iid == IID_IUnknown) || (iid == IID_IClassFactory))
{
*ppv = static_cast<IOemCF*>(this) ;
}
else
{
#if DBG && defined(USERMODE_DRIVER)
TCHAR szOutput[80] = {0};
StringFromGUID2(iid, szOutput, COUNTOF(szOutput)); // can not fail!
WARNING(DLLTEXT("IOemCF::QueryInterface %s not supported.\r\n"), szOutput);
#endif
*ppv = NULL ;
return E_NOINTERFACE ;
}
reinterpret_cast<IUnknown*>(*ppv)->AddRef() ;
return S_OK ;
}
示例11: unregister_interfaces
/***********************************************************************
* unregister_interfaces
*/
static HRESULT unregister_interfaces(struct regsvr_interface const *list) {
LONG res = ERROR_SUCCESS;
HKEY interface_key;
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
KEY_READ | KEY_WRITE, &interface_key);
if (res == ERROR_FILE_NOT_FOUND) return S_OK;
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->iid; ++list) {
WCHAR buf[39];
StringFromGUID2(list->iid, buf, 39);
res = recursive_delete_keyW(interface_key, buf);
}
RegCloseKey(interface_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
示例12: MMDevPropStore_OpenPropKey
static HRESULT MMDevPropStore_OpenPropKey(const GUID *guid, DWORD flow, HKEY *propkey)
{
WCHAR buffer[39];
LONG ret;
HKEY key;
StringFromGUID2(guid, buffer, 39);
if ((ret = RegOpenKeyExW(flow == eRender ? key_render : key_capture, buffer, 0, KEY_READ|KEY_WRITE|KEY_WOW64_64KEY, &key)) != ERROR_SUCCESS)
{
WARN("Opening key %s failed with %u\n", debugstr_w(buffer), ret);
return E_FAIL;
}
ret = RegOpenKeyExW(key, reg_properties, 0, KEY_READ|KEY_WRITE|KEY_WOW64_64KEY, propkey);
RegCloseKey(key);
if (ret != ERROR_SUCCESS)
{
WARN("Opening key %s failed with %u\n", debugstr_w(reg_properties), ret);
return E_FAIL;
}
return S_OK;
}
示例13: CoCreateGuid
Guid::Guid( void )
{
#ifdef _MSC_VER
OLECHAR guidStringPtr[40];
GUID guid;
CoCreateGuid( &guid );
# ifndef NDEBUG
int charSize =
# endif
StringFromGUID2( guid, guidStringPtr, 40 );
assert( charSize > 0 );
std::wstring wideString = guidStringPtr;
utf8::utf16to8( wideString.begin(), wideString.end(), std::back_inserter( m_string ) );
#endif
}
示例14: IsSingleThreadedApartment
BOOL IsSingleThreadedApartment()
{
HRESULT hr;
CLSID ClsID;
hr = CLSIDFromProgID(OLESTR("VPinMAME.Controller"), &ClsID);
if ( FAILED(hr) )
return FALSE;
OLECHAR sClsID[256];
StringFromGUID2(ClsID, (LPOLESTR) sClsID, 256);
char szClsID[256];
WideCharToMultiByte(CP_ACP, 0, (LPOLESTR) sClsID, -1, szClsID, sizeof szClsID, NULL, NULL);
char szRegKey[256];
lstrcpy(szRegKey, "CLSID\\");
lstrcat(szRegKey, szClsID);
lstrcat(szRegKey, "\\InprocServer32");
HKEY hKey;
if ( RegOpenKey(HKEY_CLASSES_ROOT, szRegKey, &hKey)!=ERROR_SUCCESS )
return FALSE;
char szThreadingModel[MAX_PATH];
ULONG uSize = sizeof szThreadingModel;
DWORD dwType = REG_SZ;
if ( RegQueryValueEx(hKey, "ThreadingModel", NULL, &dwType, (LPBYTE) &szThreadingModel, &uSize)!=ERROR_SUCCESS ) {
RegCloseKey(hKey);
// if we don't have that entry, return TRUE (old style, but single threaded)
return TRUE;
}
RegCloseKey(hKey);
// if we don't have that entry, return TRUE (old style, but single threaded)
if ( !szThreadingModel[0] )
return TRUE;
return _stricmp(szThreadingModel, "Apartment")?FALSE:TRUE;
}
示例15: StringFromGUID2
/*****************************************************************************
* UnregisterInprocServer()
*****************************************************************************
*/
HRESULT
UnregisterInprocServer
(
IN REFGUID ClassId
)
{
WCHAR ClsIdStr[MAX_PATH];
StringFromGUID2(ClassId, ClsIdStr, MAX_PATH);
WCHAR KeyName[MAX_PATH];
wcscpy(KeyName, L"CLSID\\"); wcscat(KeyName, ClsIdStr); wcscat(KeyName, L"\\InprocServer32");
RegDeleteKeyW(HKEY_CLASSES_ROOT, KeyName);
wcscpy(KeyName, L"CLSID\\"); wcscat(KeyName, ClsIdStr);
RegDeleteKeyW(HKEY_CLASSES_ROOT, KeyName);
return S_OK;
}