SNHookClass Class Reference

#include <lib_sn.h>

Detailed Description

Allows to register a new serial number field in the Cinema 4D serial dialog. Cinema 4D will store the serial with its own.
Just derive a class and override the virtual functions as necessary. Then create an instance of the class and call Register().
Example:

const Int32 MY_SERIAL_ID = 8564886;
class MySerial : public SNHookClass
{
private:
const String title;
public:
MySerial() : title("My Serial") {}
virtual Int32 SNCheck(const String &c4dsn,const String &sn,Int32 regdate,Int32 curdate)
{
// ...
}
virtual const String& GetTitle()
{
return title;
}
};
static MySerial* serial = nullptr;
Bool RegisterMySerial()
{
serial = NewObj(MySerial);
return serial->Register(MY_SERIAL_ID, SNFLAG_OWN);
}
void FreeMySerial()
{
DeleteObj(serial);
}
// ...
Bool PluginMessage(Int32 id, void *data)
{
// Use the following lines to set a plugin priority
switch (id)
{
if (!resource.Init())
return false;
// ...
if (!RegisterMySerial())
return false;
return true;
FreeMySerial(); return true;
// ...
}
return false;
}
Note
It is very important to allocate during C4DPL_INIT_SYS as above. Otherwise the serial checking phase is missed.
Warning
Do not store this class as static.

Public Member Functions

 SNHookClass ()
 
Bool Register (Int32 id, Int32 flags)
 
virtual Int32 SNCheck (const String &c4dsn, const String &sn, Int32 regdate, Int32 curdate)
 
virtual const StringGetTitle ()
 
virtual const CharGetClipID ()
 

Private Attributes

SNHook hook
 

Constructor & Destructor Documentation

§ SNHookClass()

Constructor.

Member Function Documentation

§ Register()

Bool Register ( Int32  id,
Int32  flags 
)

Registers the serial number.

Parameters
[in]idA unique plugin ID. Must be obtained from http://www.plugincafe.com
[in]flagsThe flags: SNFLAG
Returns
true if successful, otherwise false.

§ SNCheck()

virtual Int32 SNCheck ( const String c4dsn,
const String sn,
Int32  regdate,
Int32  curdate 
)
virtual

Override and tell Cinema 4D if a given serial number is valid.

Parameters
[in]c4dsnThe current Cinema 4D serial, without the last part of course.
[in]snThe serial that was entered for the plugin.
[in]regdateThe date of the registration, or 0 if the serial was entered for the first time.
Given in days, calculated by date = 365 * (year - 1900) + day_in_year regardless of leap years.
[in]curdateThe current date.
Returns
The serial number validity: SN_RESULT

§ GetTitle()

virtual const String& GetTitle ( )
virtual

Override and return the name of the serial number. This will show up in the serial dialog.

Returns
The name of the serial number.

§ GetClipID()

virtual const Char* GetClipID ( )
virtual

Private.

Member Data Documentation

§ hook

SNHook hook
private