Reply

Get Recent files into listview for my Custom Insert-Menu

Hello,

 

I'm developing a custom "Insert File"-window for my assembly environment, with quick access to different folders (current project, toolbox, recently used and a basic profile generator). Everything works so far (in debugging, not from within Solid Edge yet... but that's a different issue) except I can't find  the data to get recent files.

 

Anyway, I would like to add a list of recently opened files, just like the one Solid Edge has. Does anyone know where Solid Edge stores the data for this?

 

Cheerz

___________________________
The truth is .... I am Dutch
VB.NET - C# - VS Ex 2015 - ST9
3 REPLIES

Re: Get Recent files into listview for my Custom Insert-Menu

Strangly, I don't see an API way to get the values. But, they are stored in HKEY_CURRENT_USER\Software\Unigraphics Solutions\Solid Edge\Version 108\MRU so they can be read from there.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Get Recent files into listview for my Custom Insert-Menu

Wow, fast reply! Thank you Jason (I'm a fan of your work Smiley Very Happy )

 

I'm going to start learning to read from registry Smiley Happy

 

___________________________
The truth is .... I am Dutch
VB.NET - C# - VS Ex 2015 - ST9

Re: Get Recent files into listview for my Custom Insert-Menu

It works perfectly!

 

To anyone who's interested: Here's how to get the Recently Used Files in SE (HKEY location might be different, depending on your version of SE, in my case Version 107)

 

The "GetIconForExtension" is a custom function to get the default file icon available somewhere on the web. 

 

Spoiler
Dim regkey As RegistryKey
Dim i As Integer
Dim myvalue As String
Dim RecentPath As String
Dim MyItem As ListViewItem
Dim ItemExt As String
CountFolders = 0
regkey = Registry.CurrentUser.OpenSubKey("Software\Unigraphics Solutions\Solid Edge\Version 107\MRU", False)
If regkey IsNot Nothing Then
Try
For i = 1 To regkey.GetValue("FileCount", 1, RegistryValueOptions.None)
CountFolders = CountFolders + 1
myvalue = "File" & i
RecentPath = CStr(regkey.GetValue(myvalue))
ItemExt = Mid(RecentPath, RecentPath.Length - 3)
imgRecent.Images.Add(GetIconForExtension(ItemExt, IconSize.Large).ToBitmap)
MyItem = New ListViewItem
MyItem.Name = RecentPath
MyItem.Text = Mid(RecentPath, InStrRev(RecentPath, "\", -1) + 1)
MyItem.ImageKey = ItemExt
MyItem.ImageIndex = CountFolders
lstRecent.Items.Add(MyItem)
Next
Catch ex As Exception
MsgBox("Cannot read registry key. Error: " & ex.ToString)
End Try
Else
MsgBox("Registry key does not exist")
End If

 

Might not be the shortest code, but it does the job  Smiley Happy

 

Thanks Jason!

___________________________
The truth is .... I am Dutch
VB.NET - C# - VS Ex 2015 - ST9