Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sysInfo question

Status
Not open for further replies.

vecjjk

Programmer
Mar 26, 2002
34
US
I'm seeing a strange problem when using the sysInfo procedure. I have a user with a very long username (16 characters). My application logs each user as they start the application, documenting various items from sysInfo, one of which is the userName. When this guy logs in though, the value saved in my log table contains the first 15 characters of his username concatenated with the path and filename of the BDE config file. Here is the relevant code:

Code:
method UserInfoLog() logical
var
	UserSys DynArray[] AnyType
	PdoxVersion String
	DT DateTime
	UserInfoLog_TC TCURSOR
	Return_L			LOGICAL
endvar

sysInfo(UserSys)
PdoxVersion = version()
DT = dateTime()

IF UserInfoLog_TC.open(":WRS:UserInfoLog") THEN
	UserInfoLog_TC.edit()
	IF UserInfoLog_TC.qlocate(UserSys["UserName"]) THEN
	ELSE
		UserInfoLog_TC.insertRecord()
	ENDIF

	UserInfoLog_TC.UserName = UserSys["UserName"]
	UserInfoLog_TC.LastModDT = DT
	UserInfoLog_TC.PdoxEdition = UserSys["Edition"]
	UserInfoLog_TC.PdoxVersion = PdoxVersion
	UserInfoLog_TC.BDEVersion = UserSys["EngineVersion"]
	UserInfoLog_TC.BDEEngineDT = UserSys["EngineDate"]
	UserInfoLog_TC.LocalShare = UserSys["LocalShare"]
	UserInfoLog_TC.NetShare = UserSys["NetShare"]
	UserInfoLog_TC.NetDir = UserSys["NetDir"]
	UserInfoLog_TC.WinPlatform = UserSys["WindowsPlatform"]
	UserInfoLog_TC.WinVersion = UserSys["WindowsVersion"]
	UserInfoLog_TC.WinText = UserSys["WindowsText"]
	UserInfoLog_TC.CPU = UserSys["CPU"]
	UserInfoLog_TC.Memory = UserSys["Memory"]
	UserInfoLog_TC.PdoxSysDir = UserSys["ParadoxSystemDir"]
	UserInfoLog_TC.PdoxStartupDir = UserSys["StartupDir"]

	UserInfoLog_TC.close()
	Return_L = TRUE
ELSE
	Return_L = FALSE
ENDIF

RETURN Return_L
endMethod

I don't want to post my user's name, but if the user's id is averyloooongname, here is what I am seeing as the UserName stored in my table:

averyloooongnams:\Configuration Files\wts - Pdx Citrix.cfg

Notice that the last letter is missing from the username. We are currently running Paradox 9 on a Citrix server, but this user has the same issue on Paradox 10 and running the app from a desktop. The Citrix box is Windows 2000, the desktop is NT. If anyone has any idea what is going on here, or has a workaround, I'd appreciate hearing it.

Thanks.
 
vecjjk,

Hm. I'm not absolutely sure why this is happening, but I suspect the underlying problem lies in the way C++ handles strings.

As you may know, C++ strings types are (essentially) streams of characters terminated with a null character (\0). When you read that string variable, you get everything in memory from the first location that string is to the location of the null character. This means that the size of those strings is really one more than the number of characters.

If you don't allocate room for the null character in your C++ code, you can lose it. That is, if your string is 16 characters, you really need to allocate 17 characters to support it. When you read that variable in this case, you get a value containing the saved characters followed by whatever happens to be in memory until you reach a null character.

Thus, here's what I suspect happened: the R&D engineer who worked on sysInfo() for your version of Paradox only allocated 16 characters for the username in his code. This, you're getting two values returned to you: the username that was saved and the next string in memory, which appears to be the BDE configuration file.

To test this theory, try running the following script as that user on that machine:

Code:
uses "advapi32.dll"
   GetUserName( Buffer CPTR, Size CPTR ) CLONG [stdcall "GetUserNameA"]
endUses

method run(var eventInfo Event)
var
   str  String   ; Holds the user name
   li   Longint  ; Max size of the user name
   rv   Longint  ; Return Value
endVar

   li = 255
   str = fill( " ", li )
   rv = getUserName( str, li )
   str.view()

endMethod

Log in as this user and see what you get. If you get something close to what you expect, then my theory may be what's going on and you have a workaround.

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top