     There are many undocumented (by Microsoft at least) routines that are included with Windows. I needed a
fairly reliable way to check that my PDOXWIN applications would only run on the machine that they were installed on. 
I had looked at the DRWATSON.LOG file on many occassions and noticed that the USER and COMPANY name that I
entered when I installed my copy of Windows were written to this file.  I contacted Microsoft and asked for the routine
that would extract this information. They were NO help.  I then contacted Borland, who in the past has answered more
Microsoft questions than Microsoft.

     I talked to Craig in C/C++ 900 support.  He wasn't able to answer my question immediately but promised he
would research it and get back to me.  Within 2 days the result was a fax with the C++ routine that extracted the
information.

     Since I don't know the slightest thing about C or C++, Craig and Tommy (also Borland tech support) helped
me understand what the C code was doing.  I then set about translating this into ObjectPal.  The result follows.
============================================================================================

The C++ code is:

#include <windows.h>
#include <stdio.h>

const int BuffSize = 80
const int NameId = 514
const in OrganizationId = 515

int Main()
{
HINSTANCE hUser = Loadlibrary("User.exe");
char buffer(BuffSize);

LoadString(hUser, NameId, buffer, BuffSize);
printf("Name = %s\n", buffer);

LoadString(hUser, OrganizationId, buffer, BuffSize);
printf("Organization = %s\n",buffer);

FreeLibrary(hUser);
return();
}

============================================================================================

The ObjectPal code is:

uses KRNL386
LOADLIBRARY(FF CPTR) CWORD
enduses
uses USER
LOADSTRING(hUser CWORD, NameId CWORD, RETVAL CPTR, BufSize CWORD) CWORD
enduses

VAR
hUser, NameId, OrganizationId, BufSize, FF             SMALLINT
RETVAL                                  STRING
ENDVAR

Buffsize=30

hUser=LOADLIBRARY("USER.EXE")

NameId=514
RETVAL="                              "
LOADSTRING(hUser,NameId,RETVAL,Bufsize)
MSGINFO("User Name",RETVAL)

NameId=515
RETVAL="                              "
LOADSTRING(hUser,NameId,RETVAL,Bufsize)
MSGINFO("Company  Name",RETVAL)
     What happens?  I can only offer an educated guess, but it works.

hUser is assigned the return value from LOADLIBRARY, which is a function in KRNL386.  This return value is a
handle to USER.EXE.  LOADSTRING requires this handle.

NameId is the location within USER.EXE that contains the information we are looking for.
(514=User Name and 515=Company Name. This information was supplied by Craig).

Buffsize is the amount of space that these pieces of information can contain (The amount set aside in USER.EXE for
this information).

RETVAL is the variable that the information we are looking for will be plugged into.  RETVAL <must> be assigned a
value of 30 blank spaces before calling LOADSTRING.  In C/C++ you can define the size of a string variable.  In
ObjectPal you cannot.  Assigning the blank spaces was the only way that I could get the routine to work.  Try others if
you like but this works.

LOADSTRING is then told to go to USER.EXE, get the information at location 514 (515), 30 characters worth, and
return that value in RETVAL.

The result is the User Name or Company, assigned to the variable RETVAL.