Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Declare DLL call caused an exception (!!!)
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00506373
Message ID:
00506383
Views:
17
>FUNCTION SYSGetUserName
>LOCAL lcUserName, lnBufSize, RetCode, NullCharPos
>
>    lcUserName = REPLICATE(CHR(32), 80)
>    lnBufSize = 80
>
>    *---call WINAPI
>    Declare Integer GetUserName IN WIN32API String @lpBuffer, Integer nSize
>    RetCode = GetUserName(@lcUserName, lnBufSize)
>    CLEAR DLLS
>
>    *---search for the end of the string
>    NullCharPos = AT(CHR(0), lcUserName)
>    IF NullCharPos > 0 THEN
>        lcUserName = LEFT(lcUserName, NullCharPos - 1)
>    ELSE
>        lcUserName = ""
>    ENDIF
>
>    RETURN lcUserName
>
>ENDFUNC
Try adding the @ sign infront of lcUserName in the call to GetUserName, so it is called "By Reference".

Btw. There is a command for everything and I'm still finding new stuff every week. Instead of REPLICATE(CHR(32), 80), you could do a SPACE(80)

Hope that helped,
- Erik Niese-Petersen

Crazy Dane in USA.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform