当前位置: 首页>>代码示例>>C++>>正文


C++ CoCreateGuid函数代码示例

本文整理汇总了C++中CoCreateGuid函数的典型用法代码示例。如果您正苦于以下问题:C++ CoCreateGuid函数的具体用法?C++ CoCreateGuid怎么用?C++ CoCreateGuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CoCreateGuid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RegCreateKeyEx

/*****************************************************************************
 * LookupClassId()
 *****************************************************************************
 */
GUID
LookupClassId
(
	IN		LPTSTR	SymbolicLink
)
{
	GUID ClassId;

	HKEY EmuPublicKey = NULL;

	DWORD w32Error = RegCreateKeyEx(HKEY_LOCAL_MACHINE, EMU_PUBLIC_KEY, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &EmuPublicKey, NULL);

	if (ERROR_SUCCESS == w32Error)
	{
		HKEY ClassKey = NULL;

		w32Error = RegCreateKeyEx(EmuPublicKey, "{EB5A82E1-B4E7-47e8-97B0-F0751F97C2D1}", 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &ClassKey, NULL);

		if (ERROR_SUCCESS == w32Error)
		{
			TCHAR ValueName[MAX_PATH]; _tcscpy(ValueName, SymbolicLink);

			TCHAR * token = _tcschr(ValueName, '\\');

			while (token)
			{
				*token = '#';

				token = _tcschr(token+1, '\\');
			}
 
			ULONG Type = 0;
			ULONG Size = sizeof(ClassId);
						
			w32Error = RegQueryValueEx(ClassKey, ValueName, 0, &Type, PBYTE(&ClassId), &Size);

			if (ERROR_SUCCESS != w32Error)
			{
				CoCreateGuid(&ClassId);
				
				RegSetValueEx(ClassKey, ValueName, 0, REG_BINARY, (BYTE*)&ClassId, sizeof(ClassId));

				w32Error = ERROR_SUCCESS;
			}

			RegCloseKey(ClassKey);
		}

		RegCloseKey(EmuPublicKey);
	}
	
	if (ERROR_SUCCESS != w32Error)
	{
		CoCreateGuid(&ClassId);
	}

	return ClassId;
}
开发者ID:borgestrand,项目名称:winuac2,代码行数:62,代码来源:asiodll.cpp

示例2: HrGenerateUid

/**
 * Generates a new UID in outlook format. Format is described in VConverter::HrMakeBinaryUID
 *
 * @param[out]	lpStrData	returned generated UID string
 * @return		MAPI error code
 */
HRESULT HrGenerateUid(std::string *lpStrData)
{
	HRESULT hr = hrSuccess;
	std::string strByteArrayID = "040000008200E00074C5B7101A82E008";
	std::string strBinUid;
	GUID sGuid;
	FILETIME ftNow;
	ULONG ulSize = 1;

	hr = CoCreateGuid(&sGuid);
	if (hr != hrSuccess)
		goto exit;

	hr = UnixTimeToFileTime(time(NULL), &ftNow);
	if (hr != hrSuccess)
		goto exit;

	strBinUid = strByteArrayID;	// Outlook Guid
	strBinUid += "00000000";	// InstanceDate
	strBinUid += bin2hex(sizeof(FILETIME), (LPBYTE)&ftNow);
	strBinUid += "0000000000000000"; // Padding
	strBinUid += bin2hex(sizeof(ULONG), (LPBYTE)&ulSize); // always 1
	strBinUid += bin2hex(sizeof(GUID), (LPBYTE)&sGuid);	// new guid

	lpStrData->swap(strBinUid);

exit:
	return hr;
}
开发者ID:agx,项目名称:zarafa-debian,代码行数:35,代码来源:icaluid.cpp

示例3: generate

//
// guid ops
//
guid & generate(guid & v)
{
  HRESULT r;
  r = CoCreateGuid(&v);
  assert(r == S_OK);
  return v;
}
开发者ID:nakedible,项目名称:vpnease-l2tp,代码行数:10,代码来源:misc.cpp

示例4: PrintDoc

void PrintDoc(seakgOutput *pOutput, UnicodeString filename, UnicodeString name, UnicodeString uuid, UnicodeString code) {
  filename = filename.SubString(rootPath.Length()+1, filename.Length() - rootPath.Length());
  UnicodeString id = "";
//  UnicodeString id = "";

  code = encoding_html(code);
  name = encoding_html(name);

  TGUID g;
  OleCheck(CoCreateGuid(&g));
  //Sysutils::GUIDToString(g);
  //id = Sysutils::GUIDToString(g);
  //id = id.SubString(2,37) + "[" + IntToStr(g_nInc++) + "]";

  id = IntToStr(g_nInc++);
  while (id.Length() < 6)
    id = "0" + id;

  id = prefixforid + id;

  pOutput->addline("\t<doc>");
  pOutput->addline("\t\t<field name=\"id\">" + id + "</field>");
  pOutput->addline("\t\t<field name=\"project\">" + projectName + "</field>");
  pOutput->addline("\t\t<field name=\"name\">" + name + "</field>");
  pOutput->addline("\t\t<field name=\"uuid\">" + uuid.UpperCase() + "</field>");
  pOutput->addline("\t\t<field name=\"source_filepath\">" + filename + "</field>");
  pOutput->addline("\t\t<field name=\"full_source_code\">\n" + code + "\n\t\t</field>");
  pOutput->addline("\t</doc>");
};
开发者ID:sea-kg,项目名称:seakgChrysocyonParser,代码行数:29,代码来源:main.cpp

示例5: os_uuid

int os_uuid(lua_State* L)
{
	unsigned char bytes[16];
	char uuid[38];

#if PLATFORM_WINDOWS
	CoCreateGuid((GUID*)bytes);
#else
	int result;

	/* not sure how to get a UUID here, so I fake it */
	FILE* rnd = fopen("/dev/urandom", "rb");
	result = fread(bytes, 16, 1, rnd);
	fclose(rnd);
	if (!result)
		return 0;
#endif

	sprintf(uuid, "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
		bytes[0], bytes[1], bytes[2], bytes[3],
		bytes[4], bytes[5],
		bytes[6], bytes[7],
		bytes[8], bytes[9],
		bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15]);

	lua_pushstring(L, uuid);
	return 1;
}
开发者ID:zdementor,项目名称:my-deps,代码行数:28,代码来源:os_uuid.c

示例6: CHECK_HR

HRESULT WpdObjectEnumerator::CreateEnumContext(
    __inout         ContextMap*         pContextMap,
    __in            LPCWSTR             pszParentID,
    __deref_out_opt LPWSTR*             ppszEnumContext)
{

    HRESULT         hr              = S_OK;
    GUID            guidContext     = GUID_NULL;
    CComBSTR        bstrContext;
    EnumContext*    pContext        = NULL;

    if((pContextMap     == NULL) ||
       (pszParentID     == NULL) ||
       (ppszEnumContext == NULL))
    {
        hr = E_POINTER;
        CHECK_HR(hr, "Cannot have NULL parameter");
        return hr;
    }

    *ppszEnumContext = NULL;

    hr = CoCreateGuid(&guidContext);
    if (hr == S_OK)
    {
        bstrContext = guidContext;
        if(bstrContext.Length() == 0)
        {
            hr = E_OUTOFMEMORY;
            CHECK_HR(hr, "Failed to create BSTR from GUID");
        }
    }

    if (hr == S_OK)
    {
        pContext = new EnumContext();
        if(pContext != NULL)
        {
            CAtlStringW strKey = bstrContext;
            pContext->ParentID = pszParentID;

            hr = pContextMap->Add(strKey, pContext);
            CHECK_HR(hr, "Failed to add enumeration context to client context map");

            pContext->Release();
        }
        else
        {
            hr = E_OUTOFMEMORY;
            CHECK_HR(hr, "Failed to allocate enumeration context");
        }
    }

    if (hr == S_OK)
    {
        *ppszEnumContext = AtlAllocTaskWideString(bstrContext);
    }

    return hr;
}
开发者ID:kcrazy,项目名称:winekit,代码行数:60,代码来源:WpdObjectEnum.cpp

示例7: CHECK_COM

wstring Archive::get_temp_file_name() const {
  GUID guid;
  CHECK_COM(CoCreateGuid(&guid));
  wchar_t guid_str[50];
  CHECK(StringFromGUID2(guid, guid_str, ARRAYSIZE(guid_str)));
  return add_trailing_slash(arc_dir()) + guid_str + L".tmp";
}
开发者ID:landswellsong,项目名称:FAR,代码行数:7,代码来源:archive.cpp

示例8: CreateTempDir

std::string CreateTempDir()
{
#ifdef _WIN32
  TCHAR temp[MAX_PATH];
  if (!GetTempPath(MAX_PATH, temp))
    return "";

  GUID guid;
  CoCreateGuid(&guid);
  TCHAR tguid[40];
  StringFromGUID2(guid, tguid, 39);
  tguid[39] = 0;
  std::string dir = TStrToUTF8(temp) + "/" + TStrToUTF8(tguid);
  if (!CreateDir(dir))
    return "";
  dir = ReplaceAll(dir, "\\", DIR_SEP);
  return dir;
#else
  const char* base = getenv("TMPDIR") ?: "/tmp";
  std::string path = std::string(base) + "/DolphinWii.XXXXXX";
  if (!mkdtemp(&path[0]))
    return "";
  return path;
#endif
}
开发者ID:Anti-Ultimate,项目名称:dolphin,代码行数:25,代码来源:FileUtil.cpp

示例9: CoInitialize

HRESULT
CTraceSession::Create(_In_z_ LPWSTR TraceName,
                      _In_z_ LPWSTR TraceDirectory)
{
    // Copy the name and dir
    m_TraceName = TraceName;

    // Create a trace session guid
    CoInitialize(NULL);
    HRESULT hr = CoCreateGuid(&m_TraceSessionGuid);
    CoUninitialize();

    // Bail if we failed to create the guid
    if (FAILED(hr)) return hr;

    m_FileInformation.LogFileame = TraceName;
    m_FileInformation.LogFileDirectory = TraceDirectory;

    // Set the string sizes
    size_t LoggerNameSize = (m_TraceName.size() + 1) * sizeof(wchar_t);
    size_t LogFileNameSize = MAX_PATH * sizeof(wchar_t);

    // Allocate the memory
    size_t BufferSize;
    BufferSize = sizeof(EVENT_TRACE_PROPERTIES) + LoggerNameSize + LogFileNameSize;
    m_EventTraceProperties = (PEVENT_TRACE_PROPERTIES)new byte[BufferSize];
    if (m_EventTraceProperties == nullptr) return ERROR_NOT_ENOUGH_MEMORY;

    ZeroMemory(m_EventTraceProperties, BufferSize);

    // Setup the wnode header
    m_EventTraceProperties->Wnode.BufferSize = BufferSize;
    m_EventTraceProperties->Wnode.Flags = WNODE_FLAG_TRACED_GUID;
    m_EventTraceProperties->Wnode.ClientContext = 1; // consider using 2
    CopyMemory(&m_EventTraceProperties->Wnode.Guid, &m_TraceSessionGuid, sizeof(GUID));

    SYSTEMTIME SystemTime;
    GetSystemTime(&SystemTime);
    SystemTimeToFileTime(&SystemTime, (LPFILETIME)&m_EventTraceProperties->Wnode.TimeStamp);

    // Set the defaults
    m_EventTraceProperties->BufferSize = 8; //kb
    m_EventTraceProperties->LogFileMode = EVENT_TRACE_FILE_MODE_SEQUENTIAL;

    // Set the string offsets
    m_EventTraceProperties->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
    m_EventTraceProperties->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES) + LoggerNameSize;

    // Copy the trace name
    CopyMemory((LPWSTR)((byte *)m_EventTraceProperties + m_EventTraceProperties->LoggerNameOffset),
               m_TraceName.c_str(),
               LoggerNameSize);

    std::wstring LogFile = m_FileInformation.LogFileDirectory + L"\\" + m_FileInformation.LogFileame + L".etl";
    CopyMemory((LPWSTR)((byte *)m_EventTraceProperties + m_EventTraceProperties->LogFileNameOffset),
               LogFile.c_str(),
               LogFile.size() * sizeof(wchar_t));

    return S_OK;
}
开发者ID:wyrover,项目名称:development,代码行数:60,代码来源:TraceSession.cpp

示例10: create_guid

wstring create_guid() {
  GUID guid;
  CHECK_COM(CoCreateGuid(&guid));
  wchar_t guid_str[50];
  CHECK(StringFromGUID2(guid, guid_str, ARRAYSIZE(guid_str)));
  return guid_str;
}
开发者ID:landswellsong,项目名称:FAR,代码行数:7,代码来源:sysutils.cpp

示例11: CoCreateGuid

MeaGUID::MeaGUID()
{
    HRESULT hr = CoCreateGuid(&m_guid);
    if (FAILED(hr)) {
        AfxThrowOleException(hr);
    }
}
开发者ID:craigshaw,项目名称:Meazure,代码行数:7,代码来源:GUID.cpp

示例12: aafCreateGUID

void aafCreateGUID( GUID *p_guid )
{
#if defined( OS_WINDOWS )

    assert( p_guid );
    CoCreateGuid( p_guid );

#else

    // {1994bd00-69de-11d2-b6bc-fcab70ff7331}
    static GUID	sTemplate = { 0x1994bd00,  0x69de,  0x11d2,
			{ 0xb6, 0xbc, 0xfc, 0xab, 0x70, 0xff, 0x73, 0x31 } };
    static int	sInitializedTemplate = 0;


    assert( p_guid );

    if( !sInitializedTemplate )
    {
	aafUInt32	ticks = aafGetTickCount();

	time_t		timer = time( NULL );
	sTemplate.Data1 += timer + ticks;
	sInitializedTemplate = 1;
    }

    // Just bump the first member of the guid to emulate GUIDGEN behavior.
    ++sTemplate.Data1;
    *p_guid = sTemplate;

#endif    // OS_*
}
开发者ID:mcanthony,项目名称:aaf,代码行数:32,代码来源:AAFUtils.cpp

示例13: GAMEUX_RegisterGame

/*******************************************************************************
 *  GAMEUX_RegisterGame
 *
 * Internal helper function. Registers game associated with given GDF binary in
 * Game Explorer. Implemented in gameexplorer.c
 *
 * Parameters:
 *  sGDFBinaryPath                  [I]     path to binary containing GDF file in
 *                                          resources
 *  sGameInstallDirectory           [I]     path to directory, where game installed
 *                                          it's files.
 *  installScope                    [I]     scope of game installation
 *  pInstanceID                     [I/O]   pointer to game instance identifier.
 *                                          If pointing to GUID_NULL, then new
 *                                          identifier will be generated automatically
 *                                          and returned via this parameter
 */
static HRESULT GAMEUX_RegisterGame(LPCWSTR sGDFBinaryPath,
        LPCWSTR sGameInstallDirectory,
        GAME_INSTALL_SCOPE installScope,
        GUID *pInstanceID)
{
    HRESULT hr = S_OK;
    struct GAMEUX_GAME_DATA GameData;

    TRACE("(%s, %s, 0x%x, %s)\n", debugstr_w(sGDFBinaryPath), debugstr_w(sGameInstallDirectory), installScope, debugstr_guid(pInstanceID));

    GAMEUX_initGameData(&GameData);
    GameData.sGDFBinaryPath = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(sGDFBinaryPath)+1)*sizeof(WCHAR));
    lstrcpyW(GameData.sGDFBinaryPath, sGDFBinaryPath);
    GameData.sGameInstallDirectory = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(sGameInstallDirectory)+1)*sizeof(WCHAR));
    lstrcpyW(GameData.sGameInstallDirectory, sGameInstallDirectory);
    GameData.installScope = installScope;

    /* generate GUID if it was not provided by user */
    if(IsEqualGUID(pInstanceID, &GUID_NULL))
        hr = CoCreateGuid(pInstanceID);

    GameData.guidInstanceId = *pInstanceID;

    /* load data from GDF binary */
    if(SUCCEEDED(hr))
        hr = GAMEUX_ParseGDFBinary(&GameData);

    /* save data to registry */
    if(SUCCEEDED(hr))
        hr = GAMEUX_WriteRegistryRecord(&GameData);

    GAMEUX_uninitGameData(&GameData);
    TRACE("returning 0x%08x\n", hr);
    return hr;
}
开发者ID:YokoZar,项目名称:wine,代码行数:52,代码来源:gameexplorer.c

示例14: CHECK_HR

HRESULT WpdObjectResources::CreateResourceContext(
    __inout         ContextMap*     pContextMap,
    __in            LPCWSTR         pszObjectID,
    __in            REFPROPERTYKEY  ResourceKey,
    __in            BOOL            bCreateRequest,
    __deref_out_opt 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;

    if (hr == S_OK)
    {
        hr = CoCreateGuid(&guidContext);
        CHECK_HR(hr, "Failed to CoCreateGuid used for identifying the resource context");
    }

    if (hr == S_OK)
    {
        pContext = new ResourceContext();
        if(pContext == NULL)
        {
            hr = E_OUTOFMEMORY;
            CHECK_HR(hr, "Failed to allocate new resource context");
        }
    }

    if (hr == S_OK)
    {
        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 (hr == S_OK)
    {
        hr = StringFromCLSID(guidContext, ppszResourceContext);
        CHECK_HR(hr, "Failed to allocate string from GUID for resource context");
    }

    SAFE_RELEASE(pContext);

    return hr;
}
开发者ID:kcrazy,项目名称:winekit,代码行数:60,代码来源:WpdObjectResources.cpp

示例15: CoCreateGuid

int Utility::GenerateGUID(CString& sGUID)
{
    int status = 1;
    sGUID.Empty();

    strconv_t strconv;

    // Create GUID

    UCHAR *pszUuid = 0; 
    GUID *pguid = NULL;
    pguid = new GUID;
    if(pguid!=NULL)
    {
        HRESULT hr = CoCreateGuid(pguid);
        if(SUCCEEDED(hr))
        {
            // Convert the GUID to a string
            hr = UuidToStringA(pguid, &pszUuid);
            if(SUCCEEDED(hr) && pszUuid!=NULL)
            { 
                status = 0;
                sGUID = strconv.a2t((char*)pszUuid);
                RpcStringFreeA(&pszUuid);
            }
        }
        delete pguid; 
    }

    return status;
}
开发者ID:cpzhang,项目名称:zen,代码行数:31,代码来源:Utility.cpp


注:本文中的CoCreateGuid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。