Guys, below is a procedure I call in my app. It works fine until it gets to the DmWrite at which point it cause a reset. I've basically copied the code from elsewhere and tweaked it. My DBRef variable is fine. All I'm trying to do is to create the appinfo control record. I don't do anything with the structure yet but I'd like to think that once I've got the handle and converted it to a local id, then whether I initialise the structure or not is neither here nor there. Could someone take a look at this and tell me what I'm doing wrong, or perhaps what I'm not doing?

Thanks.

void PopulateDatabase(void)
{
    typedef struct
    {
        AppInfoType AppInfo;
        UInt16 Test;
    } TestDBControl;

    TestDBControl *ControlRecord = NULL;
    MemHandle Handle;
    LocalID LocalId;
    LocalID DBId;
    UInt16 CardNo;

if(DmOpenDatabaseInfo(_DBRef, &DBId, NULL, NULL, &CardNo, NULL) == errNone)
{
Handle = DmNewHandle(_DBRef, sizeof(TestDBControl));
if(Handle)
{
LocalId = MemHandleToLocalID(Handle);
if(DmSetDatabaseInfo(CardNo, DBId, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
&LocalId, NULL, NULL, NULL) == errNone)
{
ControlRecord = (TestDBControl *) MemHandleLock(Handle);
if(ControlRecord != NULL)
{
DmWrite(Handle, (UInt32) 0, ControlRecord, (UInt32) sizeof(TestDBControl));
MemPtrUnlock(ControlRecord);
}
}
MemHandleFree(Handle);
}
}
return;
}


--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to