Can you give me some vis fox 6 code to read the Windows user-id?

TIA.

Joe Kelly

Re: How to read Windows User-id by Josh

Josh
Tue May 10 13:46:52 CDT 2005

Here's some code -- I'm sure there's an easier way.. but this always works for
apps in all os' so far...

FUNCTION whoami
LOCAL lcUserName,;
lpUserIDBuffer, ;
nBufferSize, ;
RetVal

DECLARE INTEGER GetUserName IN Win32API AS GetName ;
STRING @lpUserIDBuffer, ;
INTEGER @nBufferSize


RetVal = 0
lpUserIDBuffer = SPACE(25) && Return buffer for user ID string
nBufferSize = 25 && Size of user ID return buffer

RetVal=GetName(@lpUserIDBuffer, @nBufferSize)
lcUserName = LEFT(lpUserIDBuffer,nBufferSize-1)

RETURN lcUserName

ENDFUNC



On Tue, 10 May 2005 10:11:02 -0700, Joe Kelly
<JoeKelly@discussions.microsoft.com> wrote:

>Can you give me some vis fox 6 code to read the Windows user-id?
>
>TIA.
>
>Joe Kelly


---
Remove x's to send.

Re: How to read Windows User-id by Esparta

Esparta
Tue May 10 14:00:58 CDT 2005

Check SYS(0) function ;-)

? PC_USER(1)
? PC_USER(2)

*----------------------------
FUNCTION PC_USER(tn)
*----------------------------
* Returns the PC name or username
* Parameters: tn = 1 - Returns PC name
* tn = 2 - Return the username
* By: Luis María Guayán
*----------------------------

LOCAL lc, ln

lc = SYS(0)
ln = AT('#',lc)
tn = IIF(EMPTY(tn) or type('tn')#'N',1,tn)
IF tn = 1
lc = LEFT(lc,ln-1)
ELSE
lc = SUBS(lc,ln+2)
ENDIF

RETURN lc
ENDFUNC
*---------------------------


HTH

--
¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º

Espartaco Palma Martínez
SysOp http://www.PortalFox.com
México D.F.
MoBlogs!
http://weblogs.golemproject.com/esparta/
http://www.espartha.com/blog/

Joe Kelly wrote:
> Can you give me some vis fox 6 code to read the Windows user-id?
>
> TIA.
>
> Joe Kelly

RE: How to read Windows User-id by Leemi

Leemi
Tue May 10 14:17:31 CDT 2005

Hi Joe:

Does the SYS(0) function give you the info you are seeking?

I hope this helps.

This posting is provided "AS IS" with no warranties, and confers no rights.

Sincerely,
Microsoft FoxPro Technical Support
Lee Mitchell

*-- VFP9 HAS ARRIVED!! --*
Read about all the new features of VFP9 here:
http://msdn.microsoft.com/vfoxpro/

*--Purchase VFP 9.0 here:
http://www.microsoft.com/PRODUCTS/info/product.aspx?view=22&pcid=54787e64-52
69-4500-8bf2-3f06689f4ab3&type=ovr

Keep an eye on the product lifecycle for Visual FoxPro here:
http://support.microsoft.com/default.aspx?id=fh;[ln];lifeprodv
- VFP5 Mainstream Support retired June 30th, 2003
- VFP6 Mainstream Support retired Sept. 30th, 2003

>Can you give me some vis fox 6 code to read the Windows user-id?

>TIA.

>Joe Kelly


Re: How to read Windows User-id by Fred

Fred
Tue May 10 20:24:26 CDT 2005

cUser = SUBSTR(SYS(0),AT("#",SYS(0))+2)

--
Fred
Microsoft Visual FoxPro MVP


"Joe Kelly" <JoeKelly@discussions.microsoft.com> wrote in message
news:961BCC5E-C7C8-4CF5-BF63-07A8D1791BA5@microsoft.com...
> Can you give me some vis fox 6 code to read the Windows user-id?
>
> TIA.
>
> Joe Kelly



RE: How to read Windows User-id by JoeKelly

JoeKelly
Wed May 11 02:58:02 CDT 2005

Thanks to all for your answers. This has solved my problem.

Best regards,

Joe Kelly