WORD ChangeFormat16(short int num)
{
WORD result;
BYTE high = HIBYTE(num);
BYTE low = LOBYTE(num);
result = MAKEWORD(high,low);
return result;
}
DWORD ChangeFormat32(DWORD x)
{
WORD hiword = HIWORD(x);
{
BYTE hibyte = HIBYTE(hiword);
BYTE lobyte = LOBYTE(hiword);
hiword = MAKEWORD(hibyte,lobyte);
}
WORD loword = LOWORD(x);
{
BYTE hibyte = HIBYTE(loword);
BYTE lobyte = LOBYTE(loword);
loword = MAKEWORD(hibyte,lobyte);
}
DWORD y = MAKELONG(hiword,loword);
return y;
}
void MakePdb(char *in ,int REC,int REC_SIZE char *out,char *dbid)
{
FILE *outfile;
DWORD ct=0;
ct =100*365*24*60*60;
printf("\n%u",ct);
int s1 = sizeof(Record);// your record type
char Line[80];
Record rec;
PDBHeader head;
FieldDescrType fd;
outfile = fopen(out,"w+b");
FILE *temp = fopen(in,"r");
strcpy(head.name,dbid);
head.attributes=0;
head.version=0;
head.creationDate=ChangeFormat32(ct);
head.modificationDate=ChangeFormat32(ct);
head.lastBackupDate=ChangeFormat32(ct);
head.modificationNumber=0;
head.appInfoID=0;
head.sortInfoID=0;
head.type=ChangeFormat32('abcd');
head.creator=ChangeFormat32('abdc');
head.unqueIDSeed=0;
head.nextRecordistID=0;
head.numRecords=ChangeFormat16(REC);
fwrite((&head),sizeof(head),1,outfile);
printf("%d",sizeof(Record));
for(int i=0;i<REC;i++)
{
int offset = 78 +8*(REC) +i*REC_SIZE;
fd.localChunkID=ChangeFormat32(offset);
fd.attributes=0;
fd.uid[0]=0;
fd.uid[1]=0;
fd.uid[2]=0;
fwrite(&fd,sizeof(FieldDescrType),1,outfile);
}
// your records to follow
>From: "Ron Bondy" <[EMAIL PROTECTED]>
>Reply-To: "Palm Developer Forum" <[EMAIL PROTECTED]>
>To: "Palm Developer Forum" <[EMAIL PROTECTED]>
>Subject: Creating Palm Database On Desktop
>Date: Fri, 14 Sep 2001 17:42:00 -0600
>
>
>Hi,
>
>I'm trying to create a Palm DB on the desktop. I've read the docs etc and
>am changing the byte order to account for the 'endian' differences of the
>two platforms. I've got #pragma pack(2) in my VC++ project to use 2 byte
>packing as recommended by Rhodes & McKeehan.
>
>Unfortunately when I try to copy the pdb I created to the Palm via the Palm
>Desktop software, I get the following message from the HotSync log:
>
>HotSync operation started 09/14/01 17:26:38
> - Invalid handheld file deleted: C:\Palm\BondyR\Install\oost1.pdb
>
>I've followed the Palm Docs for the PDB Database Format, but had to guess
>at
>a couple of things. Can someome tell me if any of my assumptions below are
>incorrect. I'm sure I'm doing something wrong, I'm just hoping that
>someone
>who has done this before can quickly spot something wrong below:
>
>a) I left the creationDate, modificationDate and lastBackupDate as 0
>
>b) I don't have an appInfo block, so I wrote out a 0 for the appInfoID. I
>understand that this is the offset from the beginning of the file to where
>the appInfo block is. But if you don't have an appInfo block ( and the
>doc's indicate that the appInfo block is optional ), is there a 'magic
>number' to use for the appInfoID in the header to indicate that the appInfo
>block is not present.
>
>c) ditto for the sort info block - don't have one and used 0 for the offset
>
>d) The RecordListType (pg 20 of the PDB Database Format doc) has a field
>'nextRecordListID'. Again, this is an offset to the next REcordListType.
>I
>assumed a value of 0 to indicate that there is no other list - is this
>correct?
>
>Thanks for any and all help,
>
>Ron
>
>
>
>Ron Bondy
>Citadel Software Inc.
>[EMAIL PROTECTED]
>www.citadelsoftware.ca
>(403) 374-0133 (phone)
>(403) 374-0134 (fax)
>
>
>--
>For information on using the Palm Developer Forums, or to unsubscribe,
>please see http://www.palmos.com/dev/tech/support/forums/
_________________________________________________________________
Get your FREE download of MSN Explorer at 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/