guid

How short can a GUID be?

纵然是瞬间 提交于 2020-01-12 04:23:10
问题 I know the standard GUIDs. Can they be made shorter? What is the theory behind it? 回答1: Greg Dean's answer is correct but in order to understand how a GUID is generated and why it ought not to be shortened I would highly suggest you read the article below. The Old New Thing : GUIDs are globally unique, but substrings of GUIDs aren't: A customer needed to generate an 8-byte unique value, and their initial idea was to generate a GUID and throw away the second half, keeping the first eight bytes

Represent a Guid as a set of integers

☆樱花仙子☆ 提交于 2020-01-11 10:02:43
问题 If I want to represent a guid as a set of integers how would I handle the conversion? I'm thinking along the lines of getting the byte array representation of the guid and breaking it up into the fewest possible 32 bit integers that can be converted back into the original guid. Code examples preferred... Also, what will the length of the resulting integer array be? 回答1: Somehow I had much more fun doing it this way: byte[] bytes = guid.ToByteArray(); int[] ints = new int[bytes.Length / sizeof

Represent a Guid as a set of integers

帅比萌擦擦* 提交于 2020-01-11 10:01:57
问题 If I want to represent a guid as a set of integers how would I handle the conversion? I'm thinking along the lines of getting the byte array representation of the guid and breaking it up into the fewest possible 32 bit integers that can be converted back into the original guid. Code examples preferred... Also, what will the length of the resulting integer array be? 回答1: Somehow I had much more fun doing it this way: byte[] bytes = guid.ToByteArray(); int[] ints = new int[bytes.Length / sizeof

How to get friendly device name from DEV_BROADCAST_DEVICEINTERFACE and Device Instance ID

时光怂恿深爱的人放手 提交于 2020-01-09 10:09:37
问题 I've registered a window with RegisterDeviceNotification and can successfully recieve DEV_BROADCAST_DEVICEINTERFACE messages. However, the dbcc_name field in the returned struct is always empty. The struct I have is defined as such: [StructLayout(LayoutKind.Sequential)] public struct DEV_BROADCAST_DEVICEINTERFACE { public int dbcc_size; public int dbcc_devicetype; public int dbcc_reserved; public Guid dbcc_classguid; [MarshalAs(UnmanagedType.LPStr)] public string dbcc_name; } And I'm using

How to get friendly device name from DEV_BROADCAST_DEVICEINTERFACE and Device Instance ID

﹥>﹥吖頭↗ 提交于 2020-01-09 10:07:53
问题 I've registered a window with RegisterDeviceNotification and can successfully recieve DEV_BROADCAST_DEVICEINTERFACE messages. However, the dbcc_name field in the returned struct is always empty. The struct I have is defined as such: [StructLayout(LayoutKind.Sequential)] public struct DEV_BROADCAST_DEVICEINTERFACE { public int dbcc_size; public int dbcc_devicetype; public int dbcc_reserved; public Guid dbcc_classguid; [MarshalAs(UnmanagedType.LPStr)] public string dbcc_name; } And I'm using

Why does Guid.ToByteArray() order the bytes the way it does?

蓝咒 提交于 2020-01-09 02:13:04
问题 When you call ToByteArray() on a GUID in .NET, the ordering of the bytes in the resulting array is not what you'd expect as compared to the string representation of the GUID. For example, for the following GUID represented as a string: 11223344-5566-7788-9900-aabbccddeeff The result of ToByteArray() is this: 44, 33, 22, 11, 66, 55, 88, 77, 99, 00, AA, BB, CC, DD, EE, FF Note that the order of the first four bytes is reversed. Also bytes 4 and 5 are swapped and bytes 6 and 7 are swapped. But

A TypeScript GUID class? [closed]

孤者浪人 提交于 2020-01-09 02:12:48
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Does anyone know of a good, solid, implementation of C# like GUID (UUID) in TypeScript? Could do it myself but figured I'd spare my time if someone else done it before. 回答1: There is an implementation in my TypeScript utilities based on JavaScript GUID generators. Here is the code: class Guid { static newGuid()

SCOPE_IDENTITY() for GUIDs?

巧了我就是萌 提交于 2020-01-08 16:02:37
问题 Can anyone tell me if there is an equivalent of SCOPE_IDENTITY() when using GUIDs as a primary key in SQL Server? I don't want to create the GUID first and save as a variable as we're using sequential GUIDs as our primary keys. Any idea on what the best way to retrieve the last inserted GUID primary key? 回答1: You can get the GUID back by using OUTPUT. This works when you're inserting multiple records also. CREATE TABLE dbo.GuidPk ( ColGuid uniqueidentifier NOT NULL DEFAULT NewSequentialID(),

SCOPE_IDENTITY() for GUIDs?

安稳与你 提交于 2020-01-08 16:02:26
问题 Can anyone tell me if there is an equivalent of SCOPE_IDENTITY() when using GUIDs as a primary key in SQL Server? I don't want to create the GUID first and save as a variable as we're using sequential GUIDs as our primary keys. Any idea on what the best way to retrieve the last inserted GUID primary key? 回答1: You can get the GUID back by using OUTPUT. This works when you're inserting multiple records also. CREATE TABLE dbo.GuidPk ( ColGuid uniqueidentifier NOT NULL DEFAULT NewSequentialID(),

Getting GUID of audio output device (speaker,headphones)

…衆ロ難τιáo~ 提交于 2020-01-07 03:06:57
问题 Is there way to get GUID of device (speaker,headphones) in java? Im trying to modify specific value in registry and i need this key name for instance HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{d348b8e8-3118-4a9c-9b43-422647b555ca} Last part {d348b8e8-3118-4a9c-9b43-422647b555ca} is what im looking for. In case its not possible thru java any way to do this with C++? 回答1: The MMDevice API allows you to enumerate audio device endpoints and get their