C#生成连续的GUID

 1 using System.Runtime.InteropServices;

 2 

 3 public class SequentialGuid

 4 {

 5     [System.Runtime.InteropServices.DllImport("Rpcrt4", CallingConvention = CallingConvention.StdCall, SetLastError = true)]

 6     private static extern long UuidCreateSequential(ref System.Guid ptrGuid);

 7 

 8     public static System.Guid CreateGuid()

 9     {

10         System.Guid id = System.Guid.Empty;

11         long num = SequentialGuid.UuidCreateSequential(ref id);

12         if (0L != num)

13         {

14             return System.Guid.NewGuid();

15         }

16         return id;

17     }

18 }

从上面的代码可以看出,其实就是调用winAPI来实现的。

Rpcrt4.dll -> UuidCreateSequential

你可能感兴趣的:(GUI)