Major parts of these code comes from Palm Computing Samples...
//--------------------------------------
// retrieve the Application Name
//--------------------------------------
int GetApplicationName(char * AppName)
{
LocalID theDBID;
UInt theCardNo;
VoidHand theStringHandle=0;
Err theErr;
int ok;
AppName[0]='\0';
ok=false;
// Get the database Local ID and card number of our application.
theErr = SysCurAppDatabase( &theCardNo, &theDBID );
if (!theErr) {
// Try to get db name from tAIN resource
theStringHandle = DmGetResource(ainRsc, ainID);
if (theStringHandle != NULL) {
StrCopy(AppName, MemHandleLock(theStringHandle));
MemHandleUnlock(theStringHandle);
DmReleaseResource(theStringHandle);
}
else {
// No tAIN resource, so use the name of the application's database
DmDatabaseInfo( theCardNo, theDBID, AppName, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
ok=true;
}
return ok;
}
//------------------------------------------------------
// Retrieve the Version
//-------------------------------------------------------
int GetApplicationVersionLong(long * Version)
{
LocalID theDBID;
UInt theCardNo;
VoidHand theStringHandle=0;
Err theErr;
UInt vernum;
long min, maj, fix;
int ok;
char VerString[120];
char *p;
*Version=0;
ok=false;
// Get the database Local ID and card number of our application.
theErr = SysCurAppDatabase( &theCardNo, &theDBID );
if (!theErr) {
// Try to get db name from tver resource
theStringHandle = DmGetResource(verRsc, appVersionID);
maj=0;
min=0;
fix=0;
// Take the Version String if defined
// Else we take the Version Num of the application...
if (theStringHandle != NULL) {
StrCopy(VerString, MemHandleLock(theStringHandle));
MemHandleUnlock(theStringHandle);
DmReleaseResource(theStringHandle);
// analyse la chaine pass�e
p=VerString;
maj=StrAToI(p);
while (*p>='0' && *p<='9')
p++;
p++;
min=StrAToI(p);
while (*p>='0' && *p<='9')
p++;
p++;
fix=StrAToI(p);
}
else {
// No tver resource, so use the version of the application's database
DmDatabaseInfo( theCardNo, theDBID, NULL, NULL, &vernum,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
// on lit un format identique � celui utilis� par le syst�me...
maj=vernum & 0xFF00;
maj=maj>>8;
min=vernum & 0x00F0;
min=min>>4;
fix=vernum & 0x000F;
}
*Version= (maj << 16) | (min & 0x000000FF) << 8 | (fix & 0x000000FF);
ok=true;
}
return ok;
}
I hope this help !
Laurent
"Eric" <[EMAIL PROTECTED]> a �crit dans le message news:
[EMAIL PROTECTED]
>
> I want to get the version of default app in PalmOS, but use
> DmGet1Resource('tver',ID). for the ID, it is found that ID is not fixed,
> "tver 1" and "tver 1000". how can I get the right version resource
> directly without try and error.
>
> Eric
>
>
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/