Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.4 KiB

  1. // Copyright (c) 1999 Microsoft Corporation. All Rights Reserved.
  2. #include <windows.h>
  3. #include <stdio.h>
  4. #include "dmoutils.h"
  5. // convert guid to string
  6. void DMOGuidToStrA(char *szStr, REFGUID guid) {
  7. sprintf(szStr, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
  8. guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1],
  9. guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5],
  10. guid.Data4[6], guid.Data4[7]);
  11. }
  12. void DMOGuidToStrW(WCHAR *szStr, REFGUID guid) {
  13. swprintf(szStr, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
  14. guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1],
  15. guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5],
  16. guid.Data4[6], guid.Data4[7]);
  17. }
  18. // convert string to guid
  19. BOOL DMOStrToGuidA(char *szStr, GUID *pguid) {
  20. DWORD temp[8];
  21. if (sscanf(szStr, "%08x-%04hx-%04hx-%02x%02x-%02x%02x%02x%02x%02x%02x",
  22. &pguid->Data1, &pguid->Data2, &pguid->Data3,
  23. &temp[0], &temp[1], &temp[2], &temp[3],
  24. &temp[4], &temp[5], &temp[6], &temp[7]) == 11) {
  25. for (DWORD c = 0; c < 8; c++)
  26. pguid->Data4[c] = (unsigned char)temp[c];
  27. return TRUE;
  28. }
  29. else
  30. return FALSE;
  31. }
  32. BOOL DMOStrToGuidW(WCHAR *szStr, GUID *pguid) {
  33. char szSrc[80];
  34. WideCharToMultiByte(0,0,szStr,-1,szSrc,80,NULL,NULL);
  35. return DMOStrToGuidA(szSrc, pguid);
  36. }