Guest User

Untitled

a guest
Jun 25th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. GUID guid = {0};
  2. CoCreateGuid(&guid);
  3. dwRand = guid.Data1 & 0x7FFFFFFF;
  4.  
  5. Data 1 - unsigned long
  6. Data 2 - unsigned short
  7. Data 3 - unsigned short
  8. Data 4 - unsigned char
  9.  
  10. public struct MyGuid
  11. {
  12. public int Data1;
  13. public short Data2;
  14. public short Data3;
  15. public byte[] Data4;
  16.  
  17. public MyGuid(Guid g)
  18. {
  19. byte[] gBytes = g.ToByteArray();
  20. Data1 = BitConverter.ToInt32(gBytes, 0);
  21. Data2 = BitConverter.ToInt16(gBytes, 4);
  22. Data3 = BitConverter.ToInt16(gBytes, 6);
  23. Data4 = new Byte[8];
  24. Buffer.BlockCopy(gBytes, 8, Data4, 0, 8);
  25. }
  26.  
  27. public Guid ToGuid()
  28. {
  29. return new Guid(Data1, Data2, Data3, Data4);
  30. }
  31. }
  32.  
  33. Guid g = GetGuidFromSomewhere();
  34. MyGuid mg = new MyGuid(g);
  35. mg.Data1 &= 0x7FFFFFFF;
  36. g = mg.ToGuid();
Add Comment
Please, Sign In to add comment