I came across a program some time ago called ChangeName that allows you to
change your HotSync user name.  You can get it at PalmGear
(http://makeashorterlink.com/?U3535117).

Unfortunately is blow up badly on OS5 (the fields it uses aren't being
locked properly, a warning in OS4 but OS5 needs a reset). However, it does
come with some source code that changes the HotSync username. Now I've not
tried this on OS5, but I thought it may be able to help those of you who
need to test against different usernames.

Here's the code for those to lazy to head to PalmGear to get it :-)

-------------------------------------
/*
 * updated: July 16. 2001
 *
 * Copyright (c) by Collin R. Mulliner <[EMAIL PROTECTED]>
 * http://www.mulliner.org/palm/
 *
 * Feel free to use this function in any of your programms, as long as you
give credit!
 *
 * This function gets or sets the PalmOS UserName (the HostSync name) and
UserID.
 *
 * set  : true to write/false to read
 * palm_name : pointer to 41 bytes of mem, UserName (max 40 chars) + the
zero byte
 * palm_id  : pointer to a UInt16, UserID
 */
void get_set_palm_name(Boolean set, char *palm_name, UInt16 *palm_id)
{
 DmOpenRef db_ref;
 void *res_ptr;
 MemHandle res_hand;
 UInt32 res_size;
 unsigned char *in_buffer, *out_buffer;
 UInt8 name_length;
 UInt16 i;
 UInt16 res_index;
 unsigned char ins_name_length;

 // open prefs database
 db_ref = DmOpenDatabaseByTypeCreator('pref', 'psys', dmModeReadWrite);
 // search for the name resource
 res_index = DmFindResource(db_ref, 'psys', 4, NULL); // it's a resource

 if (res_index != -1) { // resource found
  res_hand = DmGetResource('psys', 4);
  res_size = MemHandleSize(res_hand);
  res_ptr = MemHandleLock(res_hand);

  in_buffer = MemPtrNew(res_size);

  if (set) { // set it
   name_length = StrLen(palm_name);
   out_buffer = MemPtrNew(44+name_length+1);
  }
  MemMove(in_buffer, res_ptr, res_size);
  MemHandleUnlock(res_hand);

  if (!set) { // get it
   i = 1;
   while (*(in_buffer+42+i) != '\0') {
    i++;
   }
   MemMove(palm_name, in_buffer+42, i+1); // user name
   MemMove(palm_id, in_buffer+4, 2); // user id
  }

  if (set) { // set it
   DmResizeResource(res_hand, 44+name_length+1);
   res_ptr = MemHandleLock(res_hand);

   MemMove(out_buffer, in_buffer, 42);
   MemMove(out_buffer+42, palm_name, name_length+1);

   ins_name_length = (unsigned char) name_length + 1;

   MemMove(out_buffer+38, &ins_name_length, 1);

   MemMove(out_buffer+4, palm_id, 2);
   // this is the user ID

   DmWrite(res_ptr, 0, out_buffer, 44+name_length+1);
   MemHandleUnlock(res_hand);
   MemPtrFree(out_buffer);
  }

  DmReleaseResource(res_hand);
  MemPtrFree(in_buffer);
 }
 else {  // resource not found
  if (!set) { // get it
  // *(palm_name) = '\0';
  }
  else { // set it
   name_length = StrLen(palm_name);
   res_hand = DmNewResource(db_ref, 'psys', 4, 44+name_length+1);
   res_ptr = MemHandleLock(res_hand);
   out_buffer = MemPtrNew(44+name_length+1);
   MemSet(out_buffer, 0x00, 44+name_length+1);
   MemMove(out_buffer+42, palm_name, name_length+1);

   ins_name_length = (unsigned char) name_length + 1;

   MemMove(out_buffer+38, &ins_name_length, 1);

   MemMove(out_buffer+4, palm_id, 2);
   // this is the user ID

   DmWrite(res_ptr, 0, out_buffer, 44+name_length+1);
   MemHandleUnlock(res_hand);
   MemPtrFree(out_buffer);
   DmReleaseResource(res_hand);
  }
 }
 DmCloseDatabase(db_ref);
}
-------------------------------------


Oh, and I was also thinking that there should be some way to get a HotSync
to work over TCP/IP (by redirecting the cradle port to use TCP/IP (in
PalmSim Settings->Comms->Comms Ports)), thus getting that to set the HotSYnc
username - but after 5 mins of trying I gave up - no doubt someone else will
be able to spend more time on it and get it working though.


Cheers
Russell




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

Reply via email to