Hi the problem regarding this can be becoz if u try to execute outside
sysAppLaunchCmdNormalLaunch. Put your codes during
sysAppLaunchCmdNormalLaunch and see this. This works out. I think during
some launch, access to memory locations are limited. It will be great, if
some friends can add on to this.
if (eventP->data.ctlEnter.controlID == MainDisplayButton)
{
Err error = errNone;
DmOpenRef dbPtr;
UInt16 index;
UInt32 NameLen;
UInt32 IdLen;
UInt32 size;
MemHandle h;
void *ptr;
name = GetLockedPtr(appNameField); password =
GetLockedPtr(appPasswordField);
ErrFatalDisplay(name);
ErrFatalDisplay(password);
error = DmCreateDatabase (0, "Maria", 'BTez', 'F', false);
error = DmGetLastErr ();
ErrAlert (error); if (error) return error;
// Pointer to an open database reference is
returned.
//dbPtr =
DmOpenDatabaseByTypeCreator('F','john',dmModeReadWrite);
// dbPtr =
DmOpenDatabaseByTypeCreator(palmXmlDBType, palmXmlCreator,
dmModeReadWrite);
dbPtr = DmOpenDatabaseByTypeCreator('F', 'BTez',
dmModeReadWrite);
// Pass dmMaxRecordIndex to DmNewRecord to add
the record to the end of the database:
index = dmMaxRecordIndex;
// Calculate the lengh of the new record; remember two
bytes
// for null-terminating the strings:
NameLen = StrLen(name);
IdLen = StrLen(password);
size = NameLen+IdLen+2;
// Create the new record:
h = DmNewRecord(dbPtr, &index, size);
// Make sure we got a good memory handle:
if(!h)
return 1;
else
{
// Lock the handle, so we can write
to it:
ptr = MemHandleLock(h);
// We must use DmWrite to write to
the records, because it's in a
//write-protected memory area.
// Remember the terminating nulls
for the strings.
// First write the name:
DmWrite(ptr, 0, (const void *) name,
NameLen+1);
// Then write the id:
DmWrite(ptr, NameLen+1, (const void
*) password,IdLen+1);
// Remember to unlock the handle now
that we're done with it:
MemHandleUnlock(h);
// Release the record and mark it as
dirty:
DmReleaseRecord(dbPtr, index, true);
}
_________________________________________________________________
Get your FREE download of MSN Explorer at
http://explorer.msn.com/intl.asp <http://explorer.msn.com/intl.asp>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/