I found that the example in this link (the dll version) isn't completely reliable for windows 98 - if the user logs in OK it will return the correct name, but if they cancel the login dialogue (which doesn't lock them out of the PC under '98, just stops them accessing network resources) it may still return an apparently valid login name.
I would expect it to work better under NT/2000/XP but I haven't tested this.