Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Gettings Windows NT username from FPW26
Message
From
31/07/2001 14:06:14
Larry Huisingh
Lockheed Martin Information Technology
Richland, Washington, United States
 
 
To
27/07/2001 15:34:12
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Miscellaneous
Thread ID:
00536638
Message ID:
00537909
Views:
13
>I'm trying to get the Windows NT username from a FPW26 application. Looking at the API section, I found the GetUserName API function, which requires FoxTools. But the library is advapi32 (not sure about the name), which FoxTools can't seem to access; understandable, since it's obviously a Win32 DLL while FPW26 is a Win16 application.
>
>I know there was a thread about this earlier this year, cause I can find it in the search, but since I'm not a PUTM, I can't easily get to that thread.
>
>Is is possible, and can anyone point me in the right direction? Thanks!
>
>Here's what I tried
>
SET LIBRARY TO FoxTools
>=RegFN("GetUserName", "@S@I", "I", "advapi32")
>    && Error: 'ADVAPI32' is an invalid library or path name
Here's the code I received when I asked about this earlier. I believe it came from George Tasker.
------------
private plLoadTools, pcRetVal
plLoadTools = not ("FOXTOOLS.FLL" $ SET("LIBRARY"))
IF plLoadTools
* Not already loaded, so load it now
SET LIBRARY TO SYS(2004) + "FOXTOOLS.FLL" ADDITIVE
ENDIF ( NOT "FOXTOOLS.FLL" $ SET("LIBRARY") )

m.handle = RegFN("WNetGetUser", "@C@C@L", "L")
lcdevice = 'C:\'
lcbuffer = SPACE(260)
lnsize = LEN(lcbuffer)
IF CallFN(m.handle, @lcdevice, @lcbuffer, @lnsize) = 0
pcRetVal = LEFT(lcbuffer, lnsize - 1)
else
pcRetVal = ""
ENDIF
if plLoadTools
release library SYS(2004) + "FOXTOOLS.FLL"
endif
return pcRetVal

---------
Please forgive the lack of indenting. It looked indented when I pasted it in but I'm not familiar enough with this site to know how to format it properly.
Larry Huisingh
Lockheed Martin Information Technology
Richland WA USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform