![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Как получить GUID?
Pan © (2002-12-17 09:19:00)Какую функцию нужно вызывать, чтобы получить GUID?
kig (2002-12-19 16:38:00) [1]2Pan (19.12.02 14:10)
Найдите поиском по CoCreateGUID в дельфийских текстах ф-ции, которые ее пользуют. И выбирайте себе по вкусу.
Pan (2002-12-19 14:10:00) [2]А кто-нибудь сможет это грамотно перевести
на "Дельфийский" язык?
......
HRESULT CoCreateGuid
(
GUID *pguid // указатель на структуру GUID
);
Вот пример:
#include "stdafx.h"
#include "objbase.h"
#include "iostream.h"
void main()
{
HRESULT hr;
GUID guid;
hr=CoCreateGuid(&guid);
if (!FAILED(hr))
{
LPOLESTR szGUID = new WCHAR [39];
StringFromGUID2(guid,szGUID,39);
wprintf(L"Inherited ObjectType GUID: %s\n",szGUID);
}
else cout
kig (2002-12-19 00:22:00) [3]2Morfein © (18.12.02 21:34)
Винда то без сетевухи работает, но вот только при генерации гуида:
MSDN
UuidCreate
...
In Windows NT 4.0, Windows 95, DCOM release, and Windows 98, UuidCreate returns RPC_S_UUID_LOCAL_ONLYwhen the originating computer does not have an ethernet/token ring (IEEE 802.x) address. In this case, the generated UUID is a valid identifier, and is guaranteed to be unique among all UUIDs generated on the computer. However, the possibility exists that another computer without an ethernet/token ring address generated the identical UUID. Therefore you should never use this UUID to identify an object that is not strictly local to your computer. Computers with ethernet/token ring addresses generate UUIDs that are guaranteed to be globally unique.
MSDN
UuidCreateSequential
For security reasons, UuidCreate was modified so that it no longer uses a machine"s MAC address to generate UUIDs. UuidCreateSequential was introduced to allow creation of UUIDs using the MAC address of a machine"s Ethernet card.
In Windows XP/2000, UuidCreateSequential returns RPC_S_UUID_LOCAL_ONLYwhen the originating computer does not have an ethernet/token ring (IEEE 802.x) address. In this case, the generated UUID is a valid identifier, and is guaranteed to be unique among all UUIDs generated on the computer. However, the possibility exists that another computer without an ethernet/token ring address generated the identical UUID. Therefore you should never use this UUID to identify an object that is not strictly local to your computer. Computers with ethernet/token ring addresses generate UUIDs that are guaranteed to be globally unique.
Morfein (2002-12-18 21:34:00) [4]Насчёт уникального номера сетевой карты, это ты загнул...
У меня вот нет сетевой карты, но никто же не скажет, что у меня винда не работает...
C2H5OH (2002-12-18 19:38:00) [5]алгоритм вычисления guid разработан Open Software Foundation (кажется так называется эта контора). вычисляется на основе уникального номера сетевой карты, текущего времени. содержит 16 байт, шо обеспечивает ~10е27 различных нумеров, много больше чем звезд в нашей галактике, правда меньше, чем масса Юпитера в килограммах. о, как!
Anatoly Podgoretsky (2002-12-18 00:17:00) [6]Pan (17.12.02 09:23)
Ну ты какой любопытный, ну какая разница откуда, не пишут об этом
Jeer (2002-12-17 23:45:00) [7]GUID - Globally Unique Identifier
typedef struct _GUID
{
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} GUID;
Канонический вид
{5E4526AA-4DD1-D111-342D-00C04FC964FF}
MBo (2002-12-17 09:30:00) [8]CoCreateGuid
Pan (2002-12-17 09:23:00) [9]А как дельфи то его берут?
Vasily Terekhov (2002-12-17 09:21:00) [10]А Ctrl+Shift+G в дельфях нажать не достаточно?