Created
August 2, 2010 02:26
-
-
Save kzu/504034 to your computer and use it in GitHub Desktop.
Provides an easy way to create sequential guids
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
using System.Security; | |
public static class GuidUtil | |
{ | |
[SuppressUnmanagedCodeSecurity] | |
[DllImport("rpcrt4.dll", SetLastError = true)] | |
private static extern int UuidCreateSequential(out Guid value); | |
/// <summary> | |
/// Creates a new sequential guid. | |
/// </summary> | |
public static Guid CreateSequential() | |
{ | |
Guid guid; | |
Marshal.ThrowExceptionForHR(UuidCreateSequential(out guid)); | |
return guid; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These sequential guids are only reliable while the app/session is not restarted :(