Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to get path from where executable file was started
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00318165
Message ID:
00318973
Vues:
24
>>I think it was Rick Strahl who wrote a function that appeared in FoxPro Advisor that properly returned the startup path of whatever VFP module was started, including COM DLLs. I'll try to dig that up on Monday if anyone's interested.
>
>Here's the code that I use, which mostly comes from Rick's routine:
local lcProgram, ;
>  lcPath, ;
>  lcFileName, ;
>  lnBytes
>lcProgram = sys(16, 0)
>do case
>
>* In-process DLL server or Active Document.
>
>  case atc('.VFD', lcProgram) > 0 or Application.StartMode = 3
>    lcPath = home()
>
>* Out-of-process EXE server.
>
>  case Application.StartMode = 2
>    declare integer GetModuleFileName ;
>      in Win32API ;
>      integer hInst,;
>      string @lpszFileName,;
>      integer @cbFileName
>    lcFileName = space(256)
>    lnBytes    = 255
>    GetModuleFileName(0, @lcFilename, @lnBytes)
>    lnBytes    = at(chr(0), lcFilename)
>    lcFileName = iif(lnBytes > 1, substr(lcFileName, 1, lnBytes - 1), '')
>    lcPath     = justpath(lcFileName)
>
>* Standalone EXE or VFP development.
>
>  otherwise
>    lcPath = justpath(lcProgram)
>    if atc('PROCEDURE', lcPath) > 0
>      lcPath = substr(lcPath, rat(':', lcPath) - 1)
>    endif atc('PROCEDURE', lcPath) > 0
>endcase
>return addbs(upper(lcPath))
Thanks Doug. I'd forgotten about this post. Much appreciated.
George

Ubi caritas et amor, deus ibi est
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform