Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FAQ
Message
De
26/10/1999 10:12:38
 
 
À
26/10/1999 08:13:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Re: FAQ
Divers
Thread ID:
00281077
Message ID:
00281489
Vues:
14
>Hola amigo....
>Many of your friends give me the same recomendation, so I didn´t understand it, because this function return me the pcname and userid and I needed the userid only, then I wanted get the password, so it not good, because if the network give to the user access, why do you have to spent time check the password too.
>Some gays (I forgot the name) give the code to do it.
>I was talking with somebady called Rick Schummer, he or she (:-P, I dont know) give me the following code, but how and where I should put this code.

Since you don't need the password, you can get everything that you need by parsing the result of SYS(0) - everything up to the "#" is the machine name, and everything after it is the user name.

In the example shown below, you can always assume that the platform is Win32, since VFP (even VFP3) requires the Win32 platform, and the WNetGetUser() API call is supported in all of VFP's environments (even VFP3 running under the Win32S emulator under WfWG.

PARAMETER tlWin32, tlDisplayMsg
>
>DO CASE
>CASE PARAMETERS() = 0
>tlWin32 = .T.
>tlDisplayMsg = .F.
>CASE PARAMETERS() = 1
>tlDisplayMsg = .F.
>ENDCASE
>
>* Network Connection errors
>#DEFINE NO_ERROR 0
>#DEFINE WN_NOT_CONNECTED 48
>#DEFINE WN_BAD_NETNAME 50
>#DEFINE WN_BAD_LOCALNAME 51
>#DEFINE WN_DEVICE_ERROR 53
>#DEFINE WN_CONNECTION_CLOSED 54
>
>* Length of user name buffer.
>#DEFINE USER_BUFFER 255
>
>* Message box constants
>#DEFINE MB_OK 0 && OK button only
>#DEFINE MB_ICONINFORMATION 64 && Information message
>
>
>LOCAL scUser && As String * 255
>LOCAL scLocalName && As String
>LOCAL lnBufferSize && As Long
>LOCAL lnStatus && As Long
>LOCAL lcCallerID && As Character
>
>scUser = SPACE(USER_BUFFER)
>lnBufferSize = USER_BUFFER
>scLocalName = CHR(0) && Null character.
>
>
>DO CASE
>* VFP declaration on Windows 95 or Windows NT
>CASE tlWin32 = .T.
>DECLARE INTEGER WNetGetUser ;
>IN WIN32API ;
>AS WNetGetUserA ;
>STRING@ sName, ;
>STRING@ sUserName, ;
>INTEGER@ iBufferSize
>
>* VFP declaration on Windows 3.11
>OTHERWISE
>DECLARE INTEGER WNetGetUser ;
>IN user.dll ;
>AS WNetGetUserA
>
>What do you think about this.????
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform