Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What did I just Modi Comm?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00445850
Message ID:
00447275
Views:
11
>Is there a way to return the path of a modified file in VFP. So in the command window I issue Modi comm delme.prg If I right click on the window I can go to properties and see c:\temp\delme.prg. Is there a way I can get this though an API call or code?

I don't know if this is common on all platforms, but under Win98SE, everytime you open a file from the command window in VFP, a shortcut to that file appears in the Recent folder which populates the Documents menu in Windows. The problem is in finding this folder (it may be different from Windows\Recent if multiple users are setup for the machine), ordering by the time opened, and in resolving the shortcut's target path. The following snippet does this using the Windows Script Host and basing the last file on the modification/date and time.
lni = 0
oShell = CREATEOBJECT('WScript.Shell')
oFSO = CREATEOBJECT('Scripting.FileSystemObject')
lcrecent = oShell.SpecialFolders('Recent')
oFolder = oFSO.GetFolder(lcrecent)
FOR EACH oFile IN oFolder.Files
  oLink = oShell.CreateShortcut(oFile.Path)
  IF JUSTEXT(UPPER(oLink.TargetPath)) = 'PRG'
    lni = lni + 1
    DIMENSION a_prgs[lni, 2]
    a_prgs[lni, 1] = oLink.TargetPath
    a_prgs[lni, 2] = oFile.DateLastModified
  ENDIF
NEXT
oShell = NULL
oFSO = NULL
IF lni > 0
  = ASORT(a_prgs, 2, lni * 2, 1)
  MODIFY COMMAND (a_prgs[1, 1])
ENDIF
Without the WSH, you could use, ADIR() and my LNKFILES.DLL in the download section. There are, however, some problems with this approach. First, while the DLL does return some of the special folders, the Recent folder isn't among them. Second, you'd have to combine the date/times returned in ADIR() into a date/time data type for the array.
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform