Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Obtaining your local IP address
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00505053
Message ID:
00505284
Vues:
20
Are you saying that following code doesn't work in a .DLL?
oIP = createobject('MSWinsock.Winsock')
lcLocalIP = oIP.LocalIP
>I've spent a fair amount (too much) time on this and wanted to share my findings.
>
>If you are using an interactive application with a form that you can drop the winsock control onto, you can use that with the LocalIP property.
>
>If you are working with a .DLL, it seems parsing the return from IPCONFIG is the best answer:
>
>
>local lcTempFile, loWSH, lcLocalIP
>lcTempFile="LocalIP.txt"
>if file(lcTempfile)		&&erase leftovers from old run
>  erase (lcTempFile)
>endif
>loWSH=CreateObject("Wscript.Shell")
>loWSH.run("command /c ipconfig > "+lcTempfile,0,1)
>if file(lcTempFile)		&&read the file and parse it
>  lcLocalIP=upper(filetostr(lcTempFile))
>  lcLocalIP=substr(lcLocalIP, at('IP ADDRESS',lcLocalIP))
>  lcLocalIP=substr(lcLocalIP, at(':',lcLocalIP)+2)
>  lcLocalIP=substr(lcLocalIP, 1, at(chr(13),lcLocalIP)-1)
>  &&messagebox(lcLocalIP)
>endif
>
>
>This example uses windows scripting host. The second parameter tells it to not display the window, the last parameter tells it to not return until the program is finished.
>
>It's a very cool way to run DOS commands without them flashing on the screen.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform