[DllImport("rpcrt4.dll", SetLastError=true)]
static extern int UuidCreateSequential(out Guid guid);
VB Signature:
Declare Function UuidCreateSequential Lib "rpcrt4.dll" (ByRef id As Guid) As Integer
User-Defined Types:
None.
Notes:
Microsoft changed the UuidCreate function so it no longer uses the machine's MAC address as part of the UUID. Since CoCreateGuid calls UuidCreate to get its GUID, its output also changed. If you still like the GUIDs to be generated in sequential order (helpful for keeping a related group of GUIDs together in the system registry), you can use the UuidCreateSequential function.
static Guid UuidCreateSequential()
{
const int RPC_S_OK = 0;
Guid g;
int hr = UuidCreateSequential(out g);
if (hr != RPC_S_OK)
throw new ApplicationException
("UuidCreateSequential failed: " + hr);
return g;
}
Sample Code in VB:
Sub Main()
Dim myId As Guid
Dim code As Integer
code = UuidCreateSequential(myId)
If code <> 0 Then
Console.WriteLine("UuidCreateSequential failed: {0}", code)
Else
Console.WriteLine(myId)
End If
End Sub
Alternative Managed API:
Do you know one? Please contribute it!
Create a new UUID
10/02/2008 13:57:19 - -130.226.238.69
The CoCreateGuid API
16/03/2007 14:07:11 - 131.107.0.102
Create a new UUID
10/02/2008 13:57:19 - -130.226.238.69
Creates a new UUID
23/07/2007 14:59:37 - Lightchpa-217.128.142.57
The CoCreateGuid API
16/03/2007 14:07:11 - 131.107.0.102
Creates a new UUID
23/07/2007 14:59:37 - Lightchpa-217.128.142.57
Creates a new UUID
23/07/2007 14:59:37 - Lightchpa-217.128.142.57
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" in the upper right corner and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).
Profile your .NET code
Boost the performance of your application with ANTS Profiler
This download also contains the FREE PInvoke.net Visual Studio Add-in