taran
January 16th, 2000, 09:35 PM
How to clear the recent used files in windows through VB. I m opening word file at background.
thanks
Mail me : taranjit_singh@usa.net
thanks
Mail me : taranjit_singh@usa.net
|
Click to See Complete Forum and Search --> : How to clear recent used document list from window through VB taran January 16th, 2000, 09:35 PM How to clear the recent used files in windows through VB. I m opening word file at background. thanks Mail me : taranjit_singh@usa.net Lothar Haensler January 17th, 2000, 02:12 AM if you use Word 2000, you can use the Word object model. Application.RecentFiles is the collection of the recent file list. Iterate over all elements and call the Delete method of each element. taran January 17th, 2000, 04:21 AM By doing this,it clear the recent document list in MSWord but i m not able to do that for documents in start menu. Other option I saw in MSDN is using reference of Declare sub shaddtorecentdocs lib "Shell32.lib" (Byval uflags as long,byval pv as string) call shaddtorecentdocs(2,vbnullstring) But in this case i m not able to find any such reference of "shaddtorecentdocs" in API library. if u can halp me out on this i will be thankful to u. Lothar Haensler January 17th, 2000, 04:27 AM your declare statement is wrong. use the following code private Declare Sub shaddtorecentdocs Lib "Shell32.dll" Alias "SHAddToRecentDocs" (byval uflags as Long, byval pv as string) private Sub Command1_Click() Call shaddtorecentdocs(2, "m:\lah.htm") End Sub This is for ADDING documents to the recent file list... Lothar Haensler January 17th, 2000, 04:45 AM to delete from the shell's recent file list, get the location of the folder via ShGetFolderLocation (CSIDL_RECENT) API, then delete all relevant link files in that directory using VB's kill command. Cimperiali March 1st, 2002, 09:53 AM :-) Have a nice day, TheGreat, wherever Cesare Imperiali :-) Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus. The Rater MKSa March 1st, 2002, 11:26 AM 'Make reference to Microsoft Scripting Runtime private Sub Command1_Click() Dim fo as Folder, fs as FileSystemObject, file1 as File Dim FullPath as string FullPath = "c:\windows\recent\" set fs = CreateObject("Scripting.FileSystemObject") set fo = fs.GetFolder(FullPath) on error resume next for Each file1 In fo.Files Debug.print file1.Name file1.Delete true next Err.Clear End Sub deghost March 1st, 2002, 02:41 PM This code works: (taken from API-Guide with slight changes) Const CSIDL_RECENT = &H8 Const MAX_PATH = 260 private Type SHITEMID cb as Long abID as Byte End Type private Type ITEMIDLIST mkid as SHITEMID End Type private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (byval hwndOwner as Long, byval nFolder as Long, pidl as ITEMIDLIST) as Long private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (byval pidl as Long, byval pszPath as string) as Long private Sub Form_Load() Dim RecentFolder as string me.AutoRedraw = true RecentFolder = GetSpecialfolder(CSIDL_RECENT) set fs = CreateObject("Scripting.FileSystemObject") set fo = fs.GetFolder(RecentFolder) on error resume next for Each file1 In fo.Files file1.Delete true next Err.Clear End Sub private Function GetSpecialfolder(CSIDL as Long) as string Dim r as Long Dim IDL as ITEMIDLIST r = SHGetSpecialFolderLocation(100, CSIDL, IDL) If r = NOERROR then Path$ = Space$(512) r = SHGetPathFromIDList(byval IDL.mkid.cb, byval Path$) GetSpecialfolder = Left$(Path, InStr(Path, Chr$(0)) - 1) Exit Function End If GetSpecialfolder = "" End Function ---------- The @host is everywhere! ---------- codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |