File video with windows thumbnails

stoopkid

New member
Joined
Mar 27, 2011
Messages
3
Location
California
Programming Experience
Beginner
I want to display files pretty much as similarly to windows explorer when set to thumbnails as I can. Most importantly I need to be able to show thumbnails of videos and images that windows can(im aware that not all videos are supported).

I'm fairly new at this. I havn't done any programming in years and I've never been amazing at it, so I would really appreciate as much explanation as I can get. I've already got this directory list done so this is the next step in my project...

Thanks.
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,666
Location
Norway
Programming Experience
10+
Windows® API Code Pack for Microsoft® .NET Framework - Home
This pack is for .Net 3.5 and .Net 4 though, I don't know about the previous releases, you could check it out if that matters. The point is it contains managed interaction with the Shell API, including getting Explorer thumbnails for files. It also contains a ExplorerBrowser control that basically let you host a customizable Explorer view in your form.
If you decide to do things yourself you need a ListView and a ImageList. Here is a quick sample displaying the files in Pictures folder, it references the Shell library from the pack:
VB.NET:
Me.TheListView.BeginUpdate()
For Each path In IO.Directory.GetFiles(My.Computer.FileSystem.SpecialDirectories.MyPictures)
    Using shFile = Microsoft.WindowsAPICodePack.Shell.ShellFile.FromFilePath(path)
        Dim name = IO.Path.GetFileName(path)
        Using bmp = shFile.Thumbnail.Bitmap
            Me.TheImageList.Images.Add(name, bmp)
        End Using
        Me.TheListView.Items.Add(name, name)
    End Using
Next
Me.TheListView.EndUpdate()
Btw, there also exist examples out there to use the unmanged interfaces directly, but it is fairly complicated and error-prone.
 

stoopkid

New member
Joined
Mar 27, 2011
Messages
3
Location
California
Programming Experience
Beginner
Okay so I sprung for vs2010. I downloaded that pack but I don't know if I installed it properly... I added it in the components list but when I run your code there, I get an error in the Microsoft.WindowsAPICodePack.Shell..Shell Object. The line:

VB.NET:
int retCode = ShellNativeMethods.SHCreateItemFromParsingName(ParsingName, IntPtr.Zero, ref guid, out nativeShellItem);

Returns "Unable to find an entry point named 'SHCreateItemFromParsingName' in DLL 'shell32.dll'."

I tried installing the pack with the Visual Studio Command Prompt but I get the error "The tools version "3.5" is unrecognized. Available tools versions are "2.0", "4.0"."

I'm pretty in over my head with this, so if someone could advise I would really appreciate it.

Thanks
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,666
Location
Norway
Programming Experience
10+
I added it in the components list
??

What I did was simply to unzip the pack, I didn't perform any installations. From my test app I added reference to the --Shell.dll found in Binaries folder, using the Add Reference dialog > Browse tab.
 

stoopkid

New member
Joined
Mar 27, 2011
Messages
3
Location
California
Programming Experience
Beginner
I added it that way but I still get the same error.

I also couldn't find any info on this Explorer view you are talking about, if you could elaborate...
 
Last edited:

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,666
Location
Norway
Programming Experience
10+
I have no idea why you can't use the API pack library, you could try the samples bundled (source/Samples), there's one for the ExplorerBrowser also.
 
Top Bottom