Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can I get the location of my .exe
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00640175
Message ID:
00642335
Views:
18
>I like to get the path of my .exe when I run in run time.
>Is there a way to do this?
function cGetStartupPath

local buf, nlen
if  _VFP.StartMode#0  && if not development
  if _vfp.StartMode=4  &&  normal EXE
    return left(sys(16,0),rat("\",sys(16,0),1))
  else   && OLE
    LOCAL buf, nlen, cdir
    buf=space(400)
    DECLARE INTEGER GetModuleFileName in win32api Integer,String @,Integer
    * As an EXE or DLL, we need to find the home directory, 
    * not the curdir() and not
    * the dir of the runtime. The classlibrary property shows this for PRGs, but not VCXs
    IF _vfp.startmode = 3 or _vfp.startmode = 5 && inproc dll
      DECLARE INTEGER GetModuleHandle in win32api String
      nlen=GetModuleFileName(GetModuleHandle(this.cOLEserverName),@buf,len(buf))
    ELSE
      nlen=GetModuleFileName(0,@buf,len(buf))
    ENDIF
    buf = LEFTC(buf,nlen)
    return LEFTC(buf,RATC('\',buf))
  endif
else
  return addbs(SYS(5)+SYS(2003))  && previously we set default!!!!
endif    
Previous
Reply
Map
View

Click here to load this message in the networking platform