Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problems using API
Message
From
18/08/1999 11:00:23
 
 
To
18/08/1999 10:25:56
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00254972
Message ID:
00254994
Views:
19
>I am trying to use WNetGetUser in vfp. I have declared the function before using it. But for some reason I get an error, 1726 'API Library not found'. One last note, the error does not occur till after the function has already ran and returns the correct value.
>

I think something other than this API call is at fault; the WNetGetUser code is close enough to what I use that it should run reliably (there are differences in what I do to the returned value to clean it up on a successful return, but they have no effect on how the API call is made.

I would make sure that you use the code as shown; if something is issuing a CLEAR DLLS or something similar, or redeclaring the API call somewhere else after where you thought you'd already declared it, you might be getting hurt by side-effects. It's safest to issue the DECLARE...DLL in the function that uses it.

>One last note, the dll hooked up is C:\Windows\System\MPR.DLL

That's not always true - WinNT and Win9x use different providers for the WNet family of API calls; as long as you're using the WIN32API catchall as shown, you should be covered.

If you run the code in the debugger, exactly what line does the API Library not found occur on?

>
>
>Here is the function I am using:
>*==============================================================================
> * Method: GetDefaultUserName
> * Purpose: Gets the name of the user logged onto the machine at the * operating system level.
> * Author: F1 Technologies
> * Parameters:
> * Returns:
> *==============================================================================
> LOCAL ;
> lcNull, ;
> lcUserId, ;
> lnLen
>
> lcNull=""
> lcUserId=SPACE(255)
> lnLen=255
>
> * Use the WNetGetUser function in the Win32API to get the user id
> DECLARE INTEGER WNetGetUser IN WIN32API String @, String @, Integer @
> IF WNetGetUser(@lcNull,@lcUserId,@lnLen)=0
> lcUserId=UPPER(LEFT(lcUserId,AT(CHR(0),lcUserId)-1))
> ELSE
> lcUserId = ""
> ENDIF
>
> RETURN ALLTRIM(lcUserId)
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