title: How to generate Universally Unique IDentifier, UUID from LoadRunner independent of the OS
body: <p>I have experienced the need of generating UUID in LoadRunner several times while scripting but there is no in-build function to do so. I am using both linux and windows load generators.           </p>
  
  <p>Thanks to Scott Moore for writing the below code which uses windows in-build CoCreateGuid function (dependent on ole32.dll) to generate required UUID. However that code is completely dependent on windows platform and doesn't work in Linux platform.</p>
  
  <p>How can we generate UUID from Loadrunner independent of OS?</p>
  
  <pre><code>    #include "lrun.h"
      #include "web_api.h"
      #include "lrw_custom_body.h"
      #include "stdlib.h"
      #include "stdio.h"
      #include "string.h"
      int lr_guid_gen()
      {
          typedef struct _GUID
          {
              unsigned long Data1;
              unsigned short Data2;
              unsigned short Data3;
              unsigned char Data4[8];
          } GUID;
  
          GUID m_guid;
          char buf[50];
  
          lr_load_dll ("ole32.dll");
  
          CoCreateGuid(&amp;m_guid);
  
          sprintf (buf, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
          m_guid.Data1, m_guid.Data2, m_guid.Data3,
          m_guid.Data4[0], m_guid.Data4[1], m_guid.Data4[2], m_guid.Data4[3],
          m_guid.Data4[4], m_guid.Data4[5], m_guid.Data4[6], m_guid.Data4[7]);
  
          lr_save_string(buf, "PAR_GUID");
  
          return 0;
      }
  </code></pre>