Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Obtaining user ID on Novell network
Message
General information
Forum:
Visual FoxPro
Category:
Third party products
Miscellaneous
Thread ID:
00190102
Message ID:
00191438
Views:
26
>We are not familiar with Win32 API calls. Is there an easy way to use these in VFP? Do you know where I can find sample code for the WNetGetUser() function?
>

Using API calls is not difficult; the basic process is to declare the entrypoint to the .DLL, telling VFP what types of parameters to use, and then call the .DLL, passing appropriate parameters. There are numerous examples on using the API here on UT. A simple example of how WNetGetUser() would work might be:
DECLARE INTEGER WNetGetUser IN WIN32API ;
   STRING @ lpName, ;
   STRING @ lpUsername, ;
   INTEGER @ lpnLength

cDriveName = 'Z:' + CHR(0)  && the drive you want to check on
cBuffer=SPACE(200) && where the username will be returned
nLength = LEN(cBuffer) && the size of the buffer
nResult = WNetGetUser(cDriveName, @cBuffer, @nLength)
IF nResult = 0
   *  it worked, and the buffer contains the name
   ?  'UserID for the Drive Z: mapping - ' + LEFT(cBuffer, AT(CHR(0),cBuffer) - 1)
ELSE
   *  it did not work, lots of possible reasons
   *  You can determine the exact reason from the return value
   *  see the MSDN documentation for the meaning of the error codes
ENDIF
I'd strongly recommend that you get the MSDN documentation; it's provided when you purchase Visual Studio, or you can purchase an annual subscription that will provide quarterly updates to the CDs at a minimum. The documentation can also be accessed on-line via MSDN OnLine, a free service from Microsoft (http://msdn.microsoft.com).

If you don't intend to learn much about using APIs, you might well be better off buying a commercial library like NETLIB, which hide most of the details of using the APIs, and have been tailored to providing support for VFP.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform