Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Programatically Access Recent Files and Downloads Lists
Message
From
21/05/2016 18:51:12
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01636684
Message ID:
01636686
Views:
107
2 solutions as follow
1-
run/n explorer shell:recent
can be done with API shellexecute also
&&shellexecute
DECLARE INTEGER ShellExecute IN SHELL32.DLL INTEGER nWinHandle,;
                                            STRING cOperation,;
                                            STRING cFileName,;
                                            STRING cParameters,;
                                            STRING cDirectory,;
                                            INTEGER nShowWindow

result = ShellExecute(0, "open", "shell:recent","","",1)
2-
*Windows stores recent files in the special folder named "recent"
*Recent folder is defined by 0x08 and it depends on Windows OS used
*in win8.1 its "%APPDATA%\Microsoft\Windows\Recent\"
*in win10,it is "c:\Users\yousfi\AppData\Roaming\Microsoft\Windows\Recent\"
*this code can locate for this special folder and list files stored to re use if necessary.can execute each file by simple click on.

Publi yform
yform=Newobject("yRecents")
yform.Show
Read Events
Return
*
Define Class yRecents As Form
   BorderStyle = 2
   Height = 327
   Width = 620
   autocenter=.t.
   ShowWindow = 2
   AlwaysOnTop=.T.
   Caption = "Recent files opened"
   MaxButton = .F.
   Name = "Form1"

   Add Object combo1 As ComboBox With ;
      Anchor = 0, ;
      Height = 32, ;
      Left = 163, ;
      Top = 4, ;
      Width = 133, ;
      Name = "Combo1"

   Add Object grid1 As Grid With ;
      FontBold = .T., ;
      FontSize = 10, ;
      Anchor = 0, ;
      DeleteMark = .F., ;
      GridLines = 0, ;
      Height = 263, ;
      Left = 3, ;
      RecordSource = ['"zcurs"'], ;
      RowHeight = 19, ;
      Top = 43, ;
      Width = 610, ;
      ForeColor = Rgb(0,0,255), ;
      Name = "Grid1"

   Add Object label1 As Label With ;
      FontBold = .T., ;
      FontSize = 12, ;
      Anchor = 0, ;
      Caption = "", ;
      Height = 25, ;
      Left = 398, ;
      Top = 3, ;
      Width = 156, ;
      ForeColor = Rgb(255,0,0), ;
      BackColor = Rgb(255,255,0), ;
      Name = "Label1"

   Add Object label2 As Label With ;
      AutoSize = .T., ;
      BackStyle = 0, ;
      Caption = "Click on cfile to open cfile link (file or folder)with associated application", ;
      Height = 17, ;
      Left = 96, ;
      Top = 310, ;
      Width = 386, ;
      ForeColor = Rgb(255,0,0), ;
      Name = "Label2"

   Procedure my
      Lparameters nButton, nShift, nXCoord, nYCoord
      &&shellexecute
      Sele zcurs
      If Messagebox("open the link :"+Justfname(cfilename)+" ?",4+64+4096)=6
         result = ShellExecute(0, "open", cfilename,"","",1)
      Endi
   Endproc

   Procedure Init
      Set Date Long
      With Thisform.combo1
         .Value="*.*"
         .Click()
      Endwith
   Endproc

   Procedure Load
      Close Data All
      Declare Integer ShellExecute In SHELL32.Dll Integer nWinHandle,;
         STRING cOperation,;
         STRING cFileName,;
         STRING cParameters,;
         STRING cDirectory,;
         INTEGER nShowWindow
   Endproc

   Procedure combo1.Click
      m.ext=Lower(This.Value)

      Local objShell,objFolder,objFolderItem
      objShell = Createobject("Shell.Application")
      objFolder = objShell.Namespace( 0x08)
      objFolderItem = objFolder.Self

      Local m.yrep
      m.yrep=Addbs(objFolderItem.Path)
      objShell=Null
      objFolder=Null
      objFolderItem=Null

      *m.yrep="%APPDATA%\Microsoft\Windows\Recent\"
      *win8.1 : m.yrep="c:\Users\yousfi\AppData\Roaming\Microsoft\Windows\Recent\"
      gnbre=Adir(gabase,m.yrep+"*.*")
      Create Cursor ycurs (cfile c(100),cfilename c(150),modified c(90))
      For i=1 To gnbre
         xcfilename=m.yrep+Substr(gabase(i,1),1,Len(gabase(i,1))-4)
         xfile=Justfname(m.xcfilename)
         xmodified=Ttoc(gabase(i,3))+" "+gabase(i,4)
         Insert Into ycurs Values(xfile,xcfilename+".LNK",xmodified)
      Endfor

      If !m.ext=="*.*"
         Sele * From ycurs Where Lower(Justext(cfile))==Lower(m.ext) Into Cursor zcurs
         Sele zcurs
      Else
         Sele * From ycurs Into Cursor zcurs
      Endi
      Count To xr

      With Thisform.grid1
         .RecordSource=""
         .RecordSource="zcurs"
         .column2.Visible=.F.
         .column1.Width=300
         .column3.Width=300
         .RecordSourceType=1
         .column1.SetAll("mousepointer",15,"column")
         .SetAll("backcolor",Rgb(100,10,120),"header")
         .SetAll("forecolor",255,"header")
         .Themes=.F.
         .DeleteMark=.F.
         .GridLines=0
         .HeaderHeight=28
         .RowHeight=18
         .SetAll("fontbold",.T.,"header")
         .SetAll("fontsize",14,"header")
         .SetAll("DynamicBackColor","IIF(MOD(RECNO( ), 2)=0, RGB(255,255,255) , RGB(0,255,0))", "Column")
         Locate
         .Refresh
      Endwith

      Thisform.label1.Caption=Trans(xr)+" files ("+m.ext+")"
      Bindevent(Thisform.grid1.column1.text1,;
         "mousedown",Thisform,"my")
   Endproc


   Procedure combo1.Init
      With This &&can add other extensions
         .AddItem("pjx")
         .AddItem("prg")
         .AddItem("vcx")
         .AddItem("frx")
         .AddItem("txt")
         .AddItem("htm")
         .AddItem("html")
         .AddItem("exe")
         .AddItem("scx")
         .AddItem("mpr")
         .AddItem("mnx")
         .AddItem("h")
         .AddItem("pdf")
         .AddItem("doc")
         .AddItem("xls")
         .AddItem("*.*")
         .ListIndex=1
         .Style=2
      Endwith
   Endproc

   Procedure Destroy
      Clea Events
   Endproc

Enddefine
*can read more in my blog on special folders
http://yousfi.over-blog.com/2015/02/the-windows-special-folders.html
http://yousfi.over-blog.com/2015/02/last-vfp-files-opened-windows-recent.html
can also read (and download utility) from : http://www.nirsoft.net/utils/recent_files_view.html
Previous
Reply
Map
View

Click here to load this message in the networking platform