I already explicitly set the "registered" to zero in the globals section of
my program. Actually, what i did which seems to fix the problem was to
initialize "name" to some arbitrary bogus value if there is no prefs
resource.
> -----Original Message-----
> From: Gabe Dalbec [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, May 11, 1999 1:59 PM
> To: [EMAIL PROTECTED]
> Subject: RE: RegCode question
>
>
> Mitch,
>
> It looks like you just need to initialize your global variable registered
> to be false. If the prefs database is not found, then it will never set
> registered, and so it will default to whatever is already in the global,
> which I would guess in your case is uninitialized data.
>
> -Gabe
> Palm Creations
>
> > If anybody who knows RegCode wants to help me out... please do...
> >
> > Presently when I run my app the first time after it's
> > installed onto my
> > physical Palm, it tells me it's registered. It's not until I
> > go to the
> > launcher and start my app a second time does it tell me I have the
> > unregistered version.
> >
> > Below is some code I pulled from the RegCode SDK. If there is
> > no preferences
> > resource found, does that mean that "name" is just a null pointer that
> > causes regCode() to return garbage? Well, it looks like on
> > my handheld the
> > first time I run my unregistered app, EvalKey likes what it
> > sees in that
> > garbage because it returns registered == true.
> >
> > I'm using the plain vanilla algorithm where you just sum the
> > ascii values of
> > the PUN.
> >
> >
> > /*************************************************************
> > **************
> > **
> > * static Err AppStart(void)
> > * Reads preferences database for this app. Checks to see if
> > the key stored
> > * there matches the RegCode, and sets global "registered" variable
> > accordingly.
> > **************************************************************
> > **************
> > */
> > static Err AppStart(void)
> > {
> > Word prefsSize;
> > char name[dlkUserNameBufSize],*data;
> >
> > // Read the saved preferences / saved-state information.
> > prefsSize = sizeof(PreferenceType);
> >
> > if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs,
> > &prefsSize, true) != noPreferenceFound) {
> >
> > DlkGetSyncInfo(NULL, NULL, NULL, name, NULL, NULL);
> > if(!name[0]) {
> > StrCopy(name, "Emulator");
> > }
[Fawcett, Mitch] else
{
name = "unregistered"; //
arbitrary string.
}
> > data = regCode((unsigned char *)name, 1);
> > registered = EvalKey(prefs.key, data);
> > // Then I start doing some stuff...
> > .... open databases
> > .... go to startup form
> > }
> >
> > return 0;
> > }
> >
>