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


C++ UuidCreate函数代码示例

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


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

示例1: UuidCreate

	std::wstring Directory::CreateDirectoryWithUniqueName (const std::wstring & strFolderPathRoot)
    {
        UUID uuid;
        RPC_WSTR str_uuid;
        UuidCreate (&uuid);
        UuidToString (&uuid, &str_uuid);
		std::wstring pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
        pcTemplate += (TCHAR *) str_uuid;
        RpcStringFree (&str_uuid);

        int attemps = 10;
        while (!CreateDirectory(pcTemplate))
        {
            UuidCreate (&uuid);
            UuidToString (&uuid, &str_uuid);
            pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
            pcTemplate += (TCHAR *) str_uuid;
            RpcStringFree (&str_uuid);
            attemps--;

            if (0 == attemps)
            {
                pcTemplate = _T("");
            }
        }
        return pcTemplate;
    }
开发者ID:alexandervnuchkov,项目名称:core,代码行数:27,代码来源:Directory.cpp

示例2: test_UuidCreate

static void test_UuidCreate(void)
{
    UUID guid;
    BYTE version;

    UuidCreate(&guid);
    version = (guid.Data3 & 0xf000) >> 12;
    ok(version == 4 || broken(version == 1), "unexpected version %d\n",
       version);
    if (version == 4)
    {
        static UUID v4and = { 0, 0, 0x4000, { 0x80,0,0,0,0,0,0,0 } };
        static UUID v4or = { 0xffffffff, 0xffff, 0x4fff,
           { 0xbf,0xff,0xff,0xff,0xff,0xff,0xff,0xff } };
        UUID and, or;
        RPC_STATUS rslt;
        int i;
        char buf[39];

        and = guid;
        or = guid;
        /* Generate a bunch of UUIDs and mask them.  By the end, we expect
         * every randomly generated bit to have been zero at least once,
         * resulting in no bits set in the and mask except those which are not
         * randomly generated:  the version number and the topmost bits of the
         * Data4 field (treated as big-endian.)  Similarly, we expect only
         * the bits which are not randomly set to be cleared in the or mask.
         */
        for (i = 0; i < 1000; i++)
        {
            LPBYTE src, dst;

            UuidCreate(&guid);
            for (src = (LPBYTE)&guid, dst = (LPBYTE)&and;
             src - (LPBYTE)&guid < sizeof(guid); src++, dst++)
                *dst &= *src;
            for (src = (LPBYTE)&guid, dst = (LPBYTE)&or;
             src - (LPBYTE)&guid < sizeof(guid); src++, dst++)
                *dst |= *src;
        }
        ok(UuidEqual(&and, &v4and, &rslt),
           "unexpected bits set in V4 UUID: %s\n", printGuid(buf, sizeof(buf), &and));
        ok(UuidEqual(&or, &v4or, &rslt),
           "unexpected bits set in V4 UUID: %s\n", printGuid(buf, sizeof(buf), &or));
    }
    else
    {
        /* Older versions of Windows generate V1 UUIDs.  For these, there are
         * many stable bits, including at least the MAC address if one is
         * present.  Just check that Data4[0]'s most significant bits are
         * set as expected.
         */
        ok((guid.Data4[0] & 0xc0) == 0x80,
           "unexpected value in Data4[0]: %02x\n", guid.Data4[0] & 0xc0);
    }
}
开发者ID:Barrell,项目名称:wine,代码行数:56,代码来源:rpc.c

示例3: srand

void
random_c::generate_bytes(void *destination,
                         size_t num_bytes) {
  UUID uuid;

  if (!m_seeded) {
    srand(GetTickCount());
    m_seeded = true;
  }

  if (!m_tried_uuidcreate) {
    // Find out whether UuidCreate returns different
    // data in Data4 on each call by comparing up to five
    // results. If not use srand() and rand().
    UUID first_uuid;
    int i;

    m_use_uuidcreate = true;
    RPC_STATUS status = UuidCreate(&first_uuid);
    if ((RPC_S_OK == status) || (RPC_S_UUID_LOCAL_ONLY == status)) {
      for (i = 0; i < 5; ++i) {
        status = UuidCreate(&uuid);
        if (((RPC_S_OK != status) && (RPC_S_UUID_LOCAL_ONLY != status)) ||
            !memcmp(first_uuid.Data4, uuid.Data4, sizeof(uuid.Data4))) {
          m_use_uuidcreate = false;
          break;
        }
      }
    } else
      m_use_uuidcreate = false;

    m_tried_uuidcreate = true;
  }

  size_t num_written = 0;
  while (num_written < num_bytes) {
    if (m_use_uuidcreate) {
      RPC_STATUS status = UuidCreate(&uuid);
      if ((RPC_S_OK != status) && (RPC_S_UUID_LOCAL_ONLY != status)) {
        m_use_uuidcreate = false;
        continue;
      }

      int num_left = num_bytes - num_written;
      if (num_left > 8)
        num_left = 8;
      memcpy((unsigned char *)destination + num_written, &uuid.Data4, num_left);
      num_written += num_left;

    } else
      for (; num_written < num_bytes; ++num_written)
        ((unsigned char *)destination)[num_written] = (unsigned char)(256.0 * rand() / (RAND_MAX + 1.0));
  }
}
开发者ID:Azpidatziak,项目名称:mkvtoolnix,代码行数:54,代码来源:random.cpp

示例4: TEST

TEST(Guid2StrTest, RandomGUID) {
	GUID guid = { 0 };
	UuidCreate(&guid);
	Guid2Str *o = new Guid2Str(guid);
	EXPECT_TRUE(o->Str() != NULL);
	delete o;
}
开发者ID:Jianru-Lin,项目名称:MyLSP,代码行数:7,代码来源:Guid2Str.cpp

示例5: _uuuid_create

static void _uuuid_create(struct uuuid_t** uuuid, int* status, int nil)
{
	struct uuuid_t* u;
	RPC_STATUS st;

	u = uuuid_new();

	if (!u) {
		*status = UUUID_ERR;
		return;
	}

	if (nil)
		st = UuidCreateNil(&u->uuid);
	else
		st = UuidCreate(&u->uuid);

	if (st != RPC_S_OK) {
		uuuid_free(u);
		*status = UUUID_ERR;
		return;
	}

	*uuuid = u;
	*status = UUUID_OK;
}
开发者ID:jpalus,项目名称:libuuuid,代码行数:26,代码来源:uuuid-win32.c

示例6: UuidCreate

void MSVC8_Filter::write_filter_name_vs100(OutputWriter &output, int indent, const std::string &parent) const
{
	std::string new_filter;
	if (parent.length())
	{
		new_filter = parent + "\\" + name;
	}
	else
	{
		new_filter = name;
	}

	output.write_line(indent, "    <Filter Include=\"" + new_filter + "\">");

	// Create a new GUID:
	unsigned char *projectGUID = 0;
	GUID guid;
	UuidCreate(&guid);
	UuidToStringA(&guid, &projectGUID);
	_strupr((char *) projectGUID);
	std::string returnGUID = std::string("{") + ((char *) projectGUID) + std::string("}");
	RpcStringFreeA(&projectGUID);

	output.write_line(indent, "      <UniqueIdentifier>" + returnGUID + "</UniqueIdentifier>");
	output.write_line(indent, "    </Filter>");

	std::vector<MSVC8_FileItem *>::size_type index;
	for (index = 0; index < files.size(); index++)
	{
		files[index]->write_filter_name_vs100(output, indent, new_filter);
	}
}
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:32,代码来源:workspace_generator_msvc8.cpp

示例7: put_uuid_string

static int put_uuid_string(LPWSTR buffer, size_t buffer_len_cch)
{
    UUID uuid;
    RPC_STATUS status = UuidCreate(&uuid);
    HRESULT result;

    if (RPC_S_OK != status &&
            RPC_S_UUID_LOCAL_ONLY != status &&
            RPC_S_UUID_NO_ADDRESS != status) {
        giterr_set(GITERR_NET, "Unable to generate name for temp file");
        return -1;
    }

    if (buffer_len_cch < UUID_LENGTH_CCH + 1) {
        giterr_set(GITERR_NET, "Buffer too small for name of temp file");
        return -1;
    }

    result = StringCbPrintfW(
                 buffer, buffer_len_cch,
                 L"%08x%04x%04x%02x%02x%02x%02x%02x%02x%02x%02x",
                 uuid.Data1, uuid.Data2, uuid.Data3,
                 uuid.Data4[0], uuid.Data4[1], uuid.Data4[2], uuid.Data4[3],
                 uuid.Data4[4], uuid.Data4[5], uuid.Data4[6], uuid.Data4[7]);

    if (FAILED(result)) {
        giterr_set(GITERR_OS, "Unable to generate name for temp file");
        return -1;
    }

    return 0;
}
开发者ID:Mikesalinas146,项目名称:libgit2,代码行数:32,代码来源:winhttp.c

示例8: zuuid_new

zuuid_t *
zuuid_new (void)
{
    zuuid_t *self = (zuuid_t *) zmalloc (sizeof (zuuid_t));
    if (self) {
#if defined (HAVE_LIBUUID)
#   if defined (__WINDOWS__)
        UUID uuid;
        assert (sizeof (uuid) == ZUUID_LEN);
        UuidCreate (&uuid);
        zuuid_set (self, (byte *) &uuid);
#   else
        uuid_t uuid;
        assert (sizeof (uuid) == ZUUID_LEN);
        uuid_generate (uuid);
        zuuid_set (self, (byte *) uuid);
#   endif
#else
        //  No UUID system calls, so generate a random string
        byte uuid [ZUUID_LEN];
        int fd = open ("/dev/urandom", O_RDONLY);
        if (fd != -1) {
            ssize_t bytes_read = read (fd, uuid, ZUUID_LEN);
            assert (bytes_read == ZUUID_LEN);
            close (fd);
        }
        zuuid_set (self, uuid);
#endif
    }
    return self;
}
开发者ID:Q-Leap-Networks,项目名称:czmq,代码行数:31,代码来源:zuuid.c

示例9: V2vConnectorProcessInternalTx

static ULONG
V2vConnectorProcessInternalTx(V2V_CONNECTOR_STATE *vcs)
{
    unsigned available;
    volatile UCHAR *msg;
    ULONG error;
    V2V_FRAME_HEADER *header;
    V2V_POST_INTERNAL *vpi;
    RPC_STATUS rpcstat;
    size_t msize;

    printf("V2VAPP-CONNECTOR sending internal message #%d\n", vcs->txCounter + 1);
    available = v2v_nc2_producer_bytes_available(vcs->channel);
    printf("V2VAPP-CONNECTOR channel indicates minimum bytes available: 0x%x\n", available);

    if (vcs->vac->xferSize == 0) {
        printf("V2VAPP-CONNECTOR transer size 0, send nothing\n");
        return ERROR_SUCCESS;
    }
    
    if (vcs->vac->fastrx && v2v_nc2_remote_requested_fast_wakeup(vcs->channel))
        msize = MIN(vcs->vac->xferSize, vcs->vac->xferMaxFastRx);
    else
        msize = vcs->vac->xferSize;

    if (!v2v_nc2_prep_message(vcs->channel, msize, V2V_MESSAGE_TYPE_INTERNAL, 0, &msg)) {
        error = GetLastError();
        if (error == ERROR_RETRY) {
            /* No room right now, return and try again later */
            printf("V2VAPP-CONNECTOR not enough buffer space to send message #%d; retry\n", vcs->txCounter + 1);
            return ERROR_RETRY;
        }
        printf("V2VAPP-CONNECTOR transmit internal data failure; abort processing - error: 0x%x\n", error);
        return error; /* failure */
    }
    vcs->txCounter++; /* next message */
    header = (V2V_FRAME_HEADER*)msg;
    header->id = (USHORT)vcs->txCounter;
    header->type = V2V_MESSAGE_TYPE_INTERNAL;
    header->cs = 0;
    header->length = vcs->vac->xferSize;
    vpi = (V2V_POST_INTERNAL*)msg;
    rpcstat = UuidCreate(&vpi->guid);
    if (rpcstat != RPC_S_OK) {
        printf("V2VAPP-CONNECTOR UuidCreate() failed - error: 0x%x; using NULL GUID\n", rpcstat);
        memset((void*)(msg + sizeof(V2V_FRAME_HEADER)), 0, sizeof(GUID));
    }
    /* Fill it up with some data and send it */
    memset((void*)(msg + sizeof(V2V_POST_INTERNAL)),
           'X',
           (vcs->vac->xferSize - sizeof(V2V_POST_INTERNAL)));
    header->cs = V2vChecksum((const UCHAR*)msg, vcs->vac->xferSize);
    v2v_nc2_send_messages(vcs->channel);

    /* Keep the send loop going by setting the event. If there is no more room, the prep message call
       will return ERROR_RETRY and just land us back in the wait. */
    SetEvent(v2v_get_send_event(vcs->channel));

    return ERROR_SUCCESS;
}
开发者ID:OpenXT,项目名称:xc-windows,代码行数:60,代码来源:v2vum.c

示例10: initialize_display_settings

static void initialize_display_settings( HWND desktop )
{
    static const WCHAR display_device_guid_propW[] = {
        '_','_','w','i','n','e','_','d','i','s','p','l','a','y','_',
        'd','e','v','i','c','e','_','g','u','i','d',0 };
    GUID guid;
    RPC_CSTR guid_str;
    ATOM guid_atom;
    DEVMODEW dmW;

    UuidCreate( &guid );
    UuidToStringA( &guid, &guid_str );
    WINE_TRACE( "display guid %s\n", guid_str );

    guid_atom = GlobalAddAtomA( (LPCSTR)guid_str );
    SetPropW( desktop, display_device_guid_propW, ULongToHandle(guid_atom) );

    RpcStringFreeA( &guid_str );

    /* Store current display mode in the registry */
    if (EnumDisplaySettingsExW( NULL, ENUM_CURRENT_SETTINGS, &dmW, 0 ))
    {
        WINE_TRACE( "Current display mode %ux%u %u bpp %u Hz\n", dmW.dmPelsWidth,
                    dmW.dmPelsHeight, dmW.dmBitsPerPel, dmW.dmDisplayFrequency );
        ChangeDisplaySettingsExW( NULL, &dmW, 0,
                                  CDS_GLOBAL | CDS_NORESET | CDS_UPDATEREGISTRY,
                                  NULL );
    }
}
开发者ID:bpon,项目名称:wine,代码行数:29,代码来源:desktop.c

示例11: get_uuid

static void get_uuid(char *str)
{
#ifdef HAVE_WINDOWS_H
    UUID guid;
    UuidCreate(&guid);
    sprintf(str, "%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X",
	guid.Data1, guid.Data2, guid.Data3,
	guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
	guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
#elif defined(HAVE_CFUUIDCREATE)
    CFUUIDRef       myUUID;
    CFStringRef     myUUIDString;
    char            strBuffer[100];
    myUUID = CFUUIDCreate(kCFAllocatorDefault);
    myUUIDString = CFUUIDCreateString(kCFAllocatorDefault, myUUID);/* This is the safest way to obtain a C string from a CFString.*/
    CFStringGetCString(myUUIDString, str, SMPD_MAX_DBS_NAME_LEN, kCFStringEncodingASCII);
    CFRelease(myUUIDString);
#elif defined(HAVE_UUID_GENERATE)
    uuid_t guid;
    uuid_generate(guid);
    uuid_unparse(guid, str);
#else
    sprintf(str, "%X%X%X%X", rand(), rand(), rand(), rand());
#endif
}
开发者ID:OngOngoing,项目名称:219351_homework,代码行数:25,代码来源:smpd_database.c

示例12: OpcUa_P_Guid_Create

/**
* CreateGuid generates a global unique identifier. It calls the
* Win32 API function for doing this.
*/
OpcUa_Guid* OPCUA_DLLCALL OpcUa_P_Guid_Create(OpcUa_Guid* Guid)
{
#ifndef _GUID_CREATE_NOT_AVAILABLE
    if(UuidCreate((UUID*)Guid) != RPC_S_OK)
    {
        /* Error */
        Guid = OpcUa_Null;
        return OpcUa_Null;
    }

    /* Good */
    return Guid;
#else
    unsigned int *data = (unsigned int*)Guid;
    int chunks = 16 / sizeof(unsigned int);
    static const int intbits = sizeof(int)*8;
    static int randbits = 0;
    if (!randbits)
    {
        OpcUa_DateTime now;
        int max = RAND_MAX;
        do { ++randbits; } while ((max=max>>1));
        now = OpcUa_P_DateTime_UtcNow();
        srand(now.dwLowDateTime^now.dwHighDateTime);
        rand(); /* Skip first */
    }
开发者ID:biancode,项目名称:UA-AnsiC,代码行数:30,代码来源:opcua_p_guid.c

示例13: BytesRandomD

double		BytesRandomD()
{
	BYTE		Buffer[0x464];
	SHA_CTX		Context;
	int			idx;

	idx = 0;
	memcpy(Buffer, RandomSeed, SHA_DIGEST_LENGTH);
	idx += sizeof(RandomSeed);
	GlobalMemoryStatus((LPMEMORYSTATUS)&Buffer[idx]);
	idx += sizeof(MEMORYSTATUS);
	UuidCreate((UUID *)&Buffer[idx]);
	idx += sizeof(UUID);
	GetCursorPos((LPPOINT)&Buffer[idx]);
	idx += sizeof(POINT);
	*(DWORD *)(Buffer + idx) = GetTickCount();
	*(DWORD *)(Buffer + idx + 4) = GetMessageTime();
	*(DWORD *)(Buffer + idx + 8) = GetCurrentThreadId();
	*(DWORD *)(Buffer + idx + 12) = GetCurrentProcessId();
	idx += 16;
	QueryPerformanceCounter((LARGE_INTEGER *)&Buffer[idx]);
	SHA1_Init(&Context);
	SHA1_Update(&Context, Buffer, 0x464);
	SHA1_Update(&Context, "additional salt...", 0x13);
	SHA1_Final(RandomSeed, &Context);
	return BytesSHA1d(Buffer, 0x464);
}
开发者ID:DaemonOverlord,项目名称:Skype,代码行数:27,代码来源:Random.cpp

示例14: uuidcreate

static PyObject*
uuidcreate(PyObject* obj, PyObject*args)
{
    UUID result;
    wchar_t *cresult;
    PyObject *oresult;

    /* May return ok, local only, and no address.
       For local only, the documentation says we still get a uuid.
       For RPC_S_UUID_NO_ADDRESS, it's not clear whether we can
       use the result. */
    if (UuidCreate(&result) == RPC_S_UUID_NO_ADDRESS) {
        PyErr_SetString(PyExc_NotImplementedError, "processing 'no address' result");
        return NULL;
    }

    if (UuidToStringW(&result, &cresult) == RPC_S_OUT_OF_MEMORY) {
        PyErr_SetString(PyExc_MemoryError, "out of memory in uuidgen");
        return NULL;
    }

    oresult = PyUnicode_FromWideChar(cresult, wcslen(cresult));
    RpcStringFreeW(&cresult);
    return oresult;

}
开发者ID:Victor-Savu,项目名称:cpython,代码行数:26,代码来源:_msi.c

示例15: UuidCreate

ClusterMapLink::ClusterMapLink(GUID dest, GUID src) {

    UuidCreate(&UUID_inst);
    UuidCopy(&SourceClusterMapUUID,&src);
    UuidCopy(&DestinationClusterMapUUID,&dest);

}
开发者ID:Bam4d,项目名称:Neuretix-Win,代码行数:7,代码来源:ClusterMapLink.cpp


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