Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!swrinde!howland.reston.ans.net!surfnet.nl!sun4nl!Utrecht.NL.net!news
From: sbock@mc.mey.nl
Subject: DLL/C connect with Windows 95
X-Nntp-Posting-Host: mcnotes.mey.nl
Message-ID: <DnuEJr.DxE@inter.NL.net>
Sender: news@inter.NL.net (News at newsutr)
Organization: NLnet
X-Newsreader: Forte Free Agent 1.0.82
Date: Wed, 6 Mar 1996 20:19:38 GMT
Lines: 59

Can anybody help out with the next problem..
With the GetUserName function is it possible to retrieve the username
of the current thread. This is the name of the user currently logged
onto the system (In our situation a NT Server).
The help info says:
	BOOL GetUserName( 
		LPTSTR lpBuffer,	// address of name buffer
		LPDWORD nSize	// address of size of name buffer
		);
Parameters
lpBuffer
	Points to the buffer to recieve the null-terminated string
	containing the user's logon name. If this buffer is not large
	enough to contain the entire user name, the function fails.
nSize
	Pointer to a DWORD that, on input, specifies the maximum size,
	in characters, on the buffer specified by the lpBuffer
	parameter. If this buffer is not large enough to contain the
	entire user name, the function fails. If the function
	succeeds, it will place the number of characters copied to the
	buffer into the DWORD that nSize points to.

The method for accessing the C function is:
GetUserNameW: name with: length
	<C: int __stdcall  GetUserNameW(char * name, char * length)>
	^self externalAccessFailed

and I tested with:
whoAmI
| userName nameLenght |
userName :=  (String new: 5 ) gcCopyToHeap.
nameLenght := 5 gcCopyToHeap.
self GetUserNameW: userName  with: nameLenght.
Dialog confirm: 'Username: ', userName printString, ' length: ',
nameLenght printString

The Dialogbox print the message:'Username: a CPointer length:
aCPointer'.

I'm working for 1 1/2 months now with VW2.5 so PLEASE don't hurt me to
much. But.....
What am I doing wrong ? Is this the right calling/definition method ?

My envirionment is Windows 95, VW25, Win32 and NT Server 3.51.

Can anybody please help me out ....

Thanks,

Sylvester Bck
Moret Ernst & Young MC
Po 3101
3502 GC  UTRECHT
tel +31 30 2588869
fax +31 30 2588100
sbock@mc.mey.nl
100016.216@compuserve.com


