I'm trying to figure out how to add a file to the recent documents using .NET. In this post SHAddToRecentDocs doesn't add my file to recent documents it shows how to do it via C# but how do I do it with VB.NET? Is it possible?
Asked
Active
Viewed 37 times
0
-
Does this answer your question? [How to use
in VB.NET?](https://stackoverflow.com/questions/2229793/how-to-use-dllimport-in-vb-net) – Crowcoder Dec 21 '22 at 15:17 -
There are multiple c# to vb convertors online – MD Zand Dec 21 '22 at 19:09
1 Answers
0
Thank you for your help! Using https://converter.telerik.com/ I was able to figure it out.
This is what I used:
Public Enum ShellAddToRecentDocsFlags
Pidl = &H1
Path = &H2
PathW = &H3
End Enum
<DllImport("Shell32.dll", BestFitMapping:=False, ThrowOnUnmappableChar:=True)>
Private Shared Sub SHAddToRecentDocs(ByVal flag As ShellAddToRecentDocsFlags,
<MarshalAs(UnmanagedType.LPStr)> ByVal path As String)

JayJay101
- 1
- 1