>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")
>
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