Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to use the COM interface of a specific file returned by IShellFolder.GetUIObjectOf Method
The below code reports an error "Attempted to read or write protected memory" when it reaches GetUIObjectOf. Please help..


C#
IntPtr pidlroot;
ShellLib.IShellFolder pShellFolder;
pShellFolder = ShellLib.ShellFunctions.GetDesktopFolder();
ShellLib.ShellApi.SHGetFolderLocation(IntPtr.Zero,
                                      (short)ShellLib.ShellApi.CSIDL.CSIDL_DESKTOP,
                                      IntPtr.Zero,
                                      0,
                                      out pidlroot);

string sPath = "C:\\Documents and settings\\giji\\Desktop\\Class1.cs";
uint var = (uint)sPath.Length;
IntPtr pidlchild;
uint pdw=0;
pShellFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, sPath, ref var, out pidlchild,ref pdw);


Guid riid = new Guid("BB2E617C-0920-11d1-9A0B-00C04FC2D6C1");
IntPtr ppv;
uint len = 1;
uint reser = 0;
IntPtr[] arry = { pidlchild };
pShellFolder.GetUIObjectOf(IntPtr.Zero, len, arry, riid, ref reser, out ppv);




Is there any other way to get COM Interface of a specific file
Posted
Updated 29-Dec-09 21:58pm
v6

1 solution

Try this link:

http://stackoverflow.com/questions/1593079/develop-an-application-similar-to-windows-explorer[^]

And here's the pInvoke page about that method:

http://www.pinvoke.net/default.aspx/Interfaces/IShellFolder.html[^]

If you google the method name itself (like I did), you'll get hundreds of hits.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900