![]() |
Weird Serial Number issue |
Post Reply
|
| Author | ||
emberintherain
Member
Joined: 2008 Dec 23 Location: United States Online Status: Offline Posts: 487 |
Post Options
Quote Reply
Topic: Weird Serial Number issuePosted: 2010 Jan 25 at 9:59am |
|
|
User Information: Cinema 4D Version: 11Platform: Windows ; Language(s): C++ ; --------- Hello,I am trying to create an algorthim using the SerialInfo this is what I have, (minus the algorithm of course) SerialInfo si; String c4dSerial = si.nr; LONG mySN = c4dSerial.StringToLong(&err); LONG myAlgorithm = THIS THAT OR THE OTHER THING LOL String mySerial = LongToString(myAlgorithm); GePrint("C4D SERIAL NUMBER IS: " + si.nr); GePrint("USER SERIAL IS: " + mySerial); FOr some reason the GePrint C4D SERIAL NUMBER IS is printing out 0. I am doing this with my registered licensed copy of C4D so I am not sure why this is happening. Could anyone shed a little light on this for me? Thanks, ~Shawn |
||
![]() |
||
spedler
Member
Joined: 2008 Apr 19 Location: United Kingdom Online Status: Offline Posts: 96 |
Post Options
Quote Reply
Posted: 2010 Jan 25 at 11:28am |
|
|
You're missing out a step - you have to get the SerialInfo structure from C4D first:
SerialInfo si; GeGetSerialInfo(SERIAL_CINEMA4D, &si); // then the rest of your code Steve |
||
|
Steve
|
||
![]() |
||
emberintherain
Member
Joined: 2008 Dec 23 Location: United States Online Status: Offline Posts: 487 |
Post Options
Quote Reply
Posted: 2010 Jan 25 at 1:25pm |
|
|
Thank you Steve!
~Shawn |
||
![]() |
||
emberintherain
Member
Joined: 2008 Dec 23 Location: United States Online Status: Offline Posts: 487 |
Post Options
Quote Reply
Posted: 2010 Jan 25 at 2:59pm |
|
|
okay so here's the code now..
the problem I am running in to is that the LONG MySN always equals zero. My guess is that because the serial number is 11 digits, that this is too large for a long. However, in order to use StringToLong, I need to convert it to a LONG. Can anyone think of a way around this? ~Shawn |
||
![]() |
||
Mallard
Member
Joined: 2008 Nov 26 Location: Kempten, Germany Online Status: Offline Posts: 14 |
Post Options
Quote Reply
Posted: 2010 Jan 26 at 5:05am |
|
|
just a side note: it's not recommended to use the whole 11 digits since the first ones represent the C4D version and thus you'd have to create a new s/n for each customer who updates the version.
It's rather recommended using only the last 5 digits of the sn so maybe you want to use sn.nr.SubStr(6, 5) instead. There was a thread around here stating this but I'm unable to find it now... |
||
![]() |
||
spedler
Member
Joined: 2008 Apr 19 Location: United Kingdom Online Status: Offline Posts: 96 |
Post Options
Quote Reply
Posted: 2010 Jan 26 at 5:51am |
|
I had exactly the same problem. Three possible solutions: 1) do as Mallard suggests - I hadn't heard this before but it sounds good, so it would be worth looking into. 2) use a LULONG to hold the result of StringToLong(), which can take the 11 digits - but I couldn't get this to work in the R10 SDK, I don't know why; it worked OK in R11. 3) split the 11-digit serial string into two parts and check them individually, which is what I did in the end (but method 1 might have saved time!). Steve |
||
![]() |
||
emberintherain
Member
Joined: 2008 Dec 23 Location: United States Online Status: Offline Posts: 487 |
Post Options
Quote Reply
Posted: 2010 Jan 26 at 5:51am |
|
|
thanks for the info mallard. I will try that when I get home.
~Shawn
|
||
![]() |
||
emberintherain
Member
Joined: 2008 Dec 23 Location: United States Online Status: Offline Posts: 487 |
Post Options
Quote Reply
Posted: 2010 Jan 26 at 8:00am |
|
|
And thanks Steve! :) We must have posted at the exact same time because I didn't see your reply until now. LOL
|
||
![]() |
||
emberintherain
Member
Joined: 2008 Dec 23 Location: United States Online Status: Offline Posts: 487 |
Post Options
Quote Reply
Posted: 2010 Jan 26 at 3:53pm |
|
|
Awesome, thanks guys. all of your ideas and techniques have led me to a working serial number system.. Now, I have one last question on this issue. How do I make the plugin do nothing if the serial number isn't correct?
~Shawn |
||
![]() |
||
Mallard
Member
Joined: 2008 Nov 26 Location: Kempten, Germany Online Status: Offline Posts: 14 |
Post Options
Quote Reply
Posted: 2010 Jan 27 at 1:09am |
|
|
Depends whether you use SNHook or Read/WritePluginInfo
In the first case return SN_WRONGNUMBER in the latter case just leave PluginStart() returning FALSE without calling RegisterMyPlugin() |
||
![]() |
||
emberintherain
Member
Joined: 2008 Dec 23 Location: United States Online Status: Offline Posts: 487 |
Post Options
Quote Reply
Posted: 2010 Feb 06 at 9:33am |
|
|
So I set the plugin to return SN_WRONGNUMBER and I get the dialog telling me that the serial is not correct, however, if I simply press cancel from that Dialog, I am able to go in to C4D and my plugin is available. Does anyone know why this is happening?
~Shawn |
||
![]() |
||
emberintherain
Member
Joined: 2008 Dec 23 Location: United States Online Status: Offline Posts: 487 |
Post Options
Quote Reply
Posted: 2010 Feb 06 at 9:49am |
|
|
SOrry.. let me be a bit more specific...
Here's the code..
When the serial number doesn't match mySerial.. I get the box that says incorrect serial number.. however, I can just cancel out of that dialog and I am able to access C4D and my plugin is available. . This is in my full version of C4D.. Thanks, ~Shawn |
||
![]() |
||
emberintherain
Member
Joined: 2008 Dec 23 Location: United States Online Status: Offline Posts: 487 |
Post Options
Quote Reply
Posted: 2010 Feb 07 at 9:02am |
|
|
any thoughts on this?
|
||
![]() |
||
emberintherain
Member
Joined: 2008 Dec 23 Location: United States Online Status: Offline Posts: 487 |
Post Options
Quote Reply
Posted: 2010 Feb 07 at 5:23pm |
|
|
Here's all of the code that pertains to the serialization. Without the algorithm.
And here is the main.cpp
I'm a bit frustrated because I can't see why the user would be able to see the plugin when the serial number is not valid. If I start up C4D I get a message that say's WRONG SERIAL NUMBER for PLanet X Generator. Then I click cancel to bypass the serial number dialog and I go in to C4D and I am still able to use the plugin. This is all I lack to finish before the release of my plugin so you can imagine my frustration that this is not playing nice. Does anyone see anything wrong with my code? Thanks a million to the person who solves this and I will owe you a large PINT. ~Shawn |
||
![]() |
||
Matthias Bober
Forum Moderator
Joined: 2006 Oct 16 Location: Germany Online Status: Offline Posts: 1647 |
Post Options
Quote Reply
Posted: 2010 Feb 08 at 6:01am |
|
|
The SNHookClass will not prevent automatically the loading of plugins if a wrong or empty keyis entered. It only establishes a hook to the Personalize dialog. You have to check for the key independently from the dialog.
here is an example that illustrates this: main.cpp
serial_hook.cpp
cheers, Matthias Edited by Matthias Bober - 2010 Feb 08 at 6:04am |
||
|
MAXON
developer support |
||
![]() |
||
emberintherain
Member
Joined: 2008 Dec 23 Location: United States Online Status: Offline Posts: 487 |
Post Options
Quote Reply
Posted: 2010 Feb 08 at 6:30am |
|
|
Thanks a million Matthias. You've saved me yet again! I truly appreciate your efforts here at the plugin cafe. Top notch!
~Shawn
|
||
![]() |
||
Post Reply
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |