Determine Revit Demo Mode and Serial Number

Last week’s

updated Revit demo mode determination
prompted
a lively discussion between two strong Revit API experts and blog contributors,

Victor Chekalin
and

Rudolf Honke
the
Revitalizer, partly on how to further improve the demo mode detection, and mainly on the value and risks of using unsupported features in your products.

The

thread
is
well worth a read, and I like Victor’s final suggestion of reading the Revit serial number instead of using the language dependent title bar caption enough to update The Building Coder sample accordingly.
He says:

Just reference the UIFrameworkServices.dll assembly and read the Revit serial number with the InfoCenterService class static method ProductSerialNumber.
If Revit is running in demo mode, the serial number is 000-00000000.

Here is the full source code.

Simple, isn’t it?

Victor also points out that it is obviously much easier to use System.Diagnostics.Process.GetCurrentProcess().MainWindowTitle to read the Revit main window caption than to do so using the WinAPI and user32.dll functionality.

I updated the CmdDemoCheck to make use of this and report both the serial number and the demo status:


  public Result Execute(
    ExternalCommandData commandData,
    ref string message,
    ElementSet elements )
  {
    // . . .
 
    // Language independent serial number check:
 
    string serial_number = UIFrameworkServices
      .InfoCenterService.ProductSerialNumber;
 
    isDemo = serial_number.Equals( "000-00000000" );
 
    string sDemo = isDemo ? "Demo" : "Production";
 
    TaskDialog.Show(
      "Serial Number and Demo Version Check",
      string.Format(
        "Serial number: {0} : {1} version.",
        serial_number, sDemo ) );
 
    return Result.Succeeded;
  }

Running this command on my system now produces the following result:

Serial number and demo mode report

Here is
version 2013.0.100.1 of
The Building Coder samples including the updated CmdDemoCheck command and serial number detection.

Many thanks to Victor and Rudolf for their discussion and numerous creative suggestions.


Comments

5 responses to “Determine Revit Demo Mode and Serial Number”

  1. Hi, Jeremy.
    I think you should hide your serial number. Somebody may activate Revit with your serial number for illegal using.
    Regards, Victor.

  2. Dear Victor,
    Thank you for saving me from my naivity :-)
    Cheers, Jeremy.

  3. Hi Jeremy,
    Thank you very much for this post … is there another way to test if the version of revit is Educational or NFR ?
    Regards
    Waleed

  4. Dear Waleed,
    Yes, of course.
    Please just read the post above and follow the links.
    Please do so before submitting a comment next time. Thank you!
    Cheers, Jeremy.

  5. Hi Jeremy,
    Yes finding out if it is an NFR is possible by reading the title string, but that might not work for other languages.
    And I couldn’t find any other way of determining whether it is an Educational version.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading