Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2003.02.03;
Скачать: [xml.tar.bz2];

Вниз

Как получить GUID?   Найти похожие ветки 

 
Pan   (2002-12-17 09:19) [0]

Какую функцию нужно вызывать, чтобы получить GUID?


 
Vasily Terekhov   (2002-12-17 09:21) [1]

А Ctrl+Shift+G в дельфях нажать не достаточно?


 
Pan   (2002-12-17 09:23) [2]

А как дельфи то его берут?


 
MBo   (2002-12-17 09:30) [3]

CoCreateGuid


 
Jeer   (2002-12-17 23:45) [4]

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}



 
Anatoly Podgoretsky   (2002-12-18 00:17) [5]

Pan (17.12.02 09:23)
Ну ты какой любопытный, ну какая разница откуда, не пишут об этом


 
C2H5OH   (2002-12-18 19:38) [6]

алгоритм вычисления guid разработан Open Software Foundation (кажется так называется эта контора). вычисляется на основе уникального номера сетевой карты, текущего времени. содержит 16 байт, шо обеспечивает ~10е27 различных нумеров, много больше чем звезд в нашей галактике, правда меньше, чем масса Юпитера в килограммах. о, как!


 
Morfein   (2002-12-18 21:34) [7]

Насчёт уникального номера сетевой карты, это ты загнул...
У меня вот нет сетевой карты, но никто же не скажет, что у меня винда не работает...


 
kig   (2002-12-19 00:22) [8]

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_ONLY when 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_ONLY when 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.



 
Pan   (2002-12-19 14:10) [9]

А кто-нибудь сможет это грамотно перевести
на "Дельфийский" язык?

......

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 << "Error create Guid" << endl;
}

В результате в окне Вы увиде сформированный GUID:

Inherited ObjectType GUID: {75A73880-02BF-11D5-B4A9-E0034BC10000}
Press any key to continue

Только сам GUID будет другим, ведь он же уникальный.


 
kig   (2002-12-19 16:38) [10]

2Pan (19.12.02 14:10)

Найдите поиском по CoCreateGUID в дельфийских текстах ф-ции, которые ее пользуют. И выбирайте себе по вкусу.



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2003.02.03;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.021 c
1-4917
Checist [root]
2003-01-26 00:46
2003.02.03
Нажатие клавиши


3-4793
SLON_EKTB
2003-01-16 22:05
2003.02.03
Проблемма работы IB в сервисе NT


14-5175
sagchat
2003-01-12 13:15
2003.02.03
Посоветуйте какой комп взять


14-5215
ledzzz
2003-01-15 15:30
2003.02.03
barcode-компоненты для Delphi5


1-4847
oomneeq
2003-01-24 13:25
2003.02.03
Ecть ли такая функция?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский