Note that there are some explanatory texts on larger screens.

plurals
  1. POReferencing shell32 again, C# Visual Studio
    text
    copied!<p>Hmmm. Okay after revisiting PInvoke, I'm sure that I don't quite get it :-/ (just asked <a href="https://stackoverflow.com/questions/2133346/c-visual-studio-2008-reference-to-system32-dll-how">this question</a>)</p> <p>Let me illustrate the code I need to handle. It works when I use "Add Reference --> COM --> Microsoft Shell Controls and Automatation" ... but sadly it places a reference in my project that looks like this: "C:\Users\Tim\Documents\Visual Studio 2008\Projects\Wing\FileWing\obj\Debug\Interop.Shell32.dll"</p> <p>I'm digging though the recycling bin and seek for a item that I want to recover. Is there any way NOT fighting through the PInvoke to get this done? Or to get a reference to the system32/shell32.dll that lets me use this code at runtime? </p> <pre><code>private void recoverRecyclerBinEntry(string fileName, int size) { try { Shell Shl = new Shell(); Folder Recycler = Shl.NameSpace(10); // scans through all the recyclers entries till the one to recover has been found for (int i = 0; i &lt; Recycler.Items().Count; i++) { FolderItem FI = Recycler.Items().Item(i); string FileName = Recycler.GetDetailsOf(FI, 0); if (Path.GetExtension(FileName) == "") FileName += Path.GetExtension(FI.Path); //Necessary for systems with hidden file extensions. string FilePath = Recycler.GetDetailsOf(FI, 1); string combinedPath = Path.Combine(FilePath, FileName); if (size == FI.Size &amp;&amp; fileName == combinedPath) { Debug.Write("Match found. Restoring " + combinedPath + "..."); Undelete(FI); Debug.WriteLine("done."); } else { Debug.WriteLine("No match"); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); } } private bool Undelete(FolderItem Item) { try { foreach (FolderItemVerb FIVerb in Item.Verbs()) { if ( (FIVerb.Name.ToUpper().Contains("WIEDERHERSTELLEN")) || (FIVerb.Name.ToUpper().Contains("ESTORE")) || (FIVerb.Name.ToUpper().Contains("NDELETE")) ) { FIVerb.DoIt(); return true; } } //execute the first one: Item.Verbs().Item(0).DoIt(); return true; } catch (Exception) { Debug.WriteLine("ERROR undeleting"); return false; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload