Skip to content

Instantly share code, notes, and snippets.

@kzu
Created August 2, 2010 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kzu/504034 to your computer and use it in GitHub Desktop.
Save kzu/504034 to your computer and use it in GitHub Desktop.
Provides an easy way to create sequential guids
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;
}
}
@kzu
Copy link
Author

kzu commented Sep 1, 2010

These sequential guids are only reliable while the app/session is not restarted :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment