2 Replies Latest reply on Oct 11, 2012 2:23 PM by Krishnan Suresh

    Get Serial Number via C++ API?

    Krishnan Suresh

      From "About Solidworks ..." I can get the 16 digit serial number.

      Can I get the same from via an API call, i.e., is there an API function to retrieve

      the current serial number of Solidworks installation?




        • Re: Get Serial Number via C++ API?
          Keith Rice



          I am not aware of any API call that lets you get it, however, you can get it from the registry. HKEY_LOCAL_MACHINE\SOFTWARE\SolidWorks\Licenses\Serial Numbers



          Video Tutorials for the SolidWorks API

            • Re: Get Serial Number via C++ API?
              Krishnan Suresh

              Thanks! That was a great help.


              Here is the code (if anyone is interested) that returns the serial number as a string


              #include <windows.h>

              #include <malloc.h>

              #include <stdio.h>


              #define BUFFER 8192


              void main()


                  char value[256];

                  char serialNumber[256];

                  int count;

                  DWORD BufferSize = BUFFER;

                  RegGetValue(HKEY_LOCAL_MACHINE, L"SOFTWARE\\SolidWorks\\Licenses\\Serial Numbers", L"SolidWorks", REG_SZ, NULL, (PVOID)&value, &BufferSize);

                  count = 0;

                  for (int i =0; i < 64;i+=1){

                      if ((value[i] < '0') || (value[i] > '9')) continue;

                      serialNumber[count++] = value[i];

                      if (count == 15) break;


                  serialNumber[count] = '\0';

                  printf("%s \n",serialNumber);