Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to determine IP or server name where EXE is running
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows 2003 Server
Divers
Thread ID:
01228260
Message ID:
01228263
Vues:
20
>I have an application in the works that will be installed on multiple servers. In each of these installs, the application scans for certain tables, creates a TXT file in a shared folder and then needs to call BULK INSERT on a SQL Server to upload the data.
>
>I need to determine the UNC name for the share I create the TXT file in, so I can pass it as a parameter for the BULK INSERT call.
>
>How do I determine the UNC name?

Try this
CLEAR
? GetUnc([K:])
RETURN

FUNCTION GetUnc(lcMapedDevice)
DECLARE INTEGER WNetGetConnection IN Win32API ;
   STRING   @cLocalDrive, ;
   STRING   @cRemoteUNCBuffer, ;
   INTEGER  @nSizeOfBuffer
cBuffer = SPACE(511)
nResult = WNetGetConnection(lcMapedDevice, ;
                            @cBuffer, ;
                            511)
IF nResult # 0
   *  Failed - it's probably not a mapped drive,
   *  or nothing is mapped to it
   RETURN ''
ELSE
   RETURN LEFT(cBuffer,AT(CHR(0),cBuffer)-1)
ENDIF
HTH
_______________________________________________________________
Testing displays the presence, not the absence of bugs.
If a software application has to be designed, it has to be designed correctly!
_______________________________________________________________
Vladimir Zografski
Systems Analyst
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform