Hmmm. De acuerdo después de volver a visitar PInvoke, estoy seguro de que no lo entiendo: -/(solo se lo solicité this question)Haciendo referencia a shell32 nuevamente, C# Visual Studio
Déjenme ilustrar el código que debo manejar. Funciona cuando uso "Agregar referencia -> COM -> Microsoft Shell Controls and Automatation" ... pero lamentablemente pone una referencia en mi proyecto que se ve así: "C: \ Users \ Tim \ Documents \ Visual Studio 2008 \ Projects \ Wing \ FileWing \ obj \ Debug \ Interop.Shell32.dll "
Estoy cavando en la papelera de reciclaje y busco un artículo que quiero recuperar. ¿Hay alguna manera de NO pelear a través de PInvoke para hacer esto? ¿O para obtener una referencia al system32/shell32.dll que me permite usar este código en tiempo de ejecución?
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 < 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 && 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;
}
}
En primer lugar, perdón, acabo de terminar la universidad y no enseñan winapis allí ;-) Bien, entonces uso interoperabilidad COM. Usted dice que necesito una referencia al ensamblado de interoperabilidad. Supongo que esto es todo esto, que es bastante pequeño y está bien para mí: .. \ Visual Studio 2008 \ Proyectos \ Wing \ FileWing \ obj \ Debug \ Interop.Shell32.dll Ahora mi pregunta es: ¿cómo puedo influir? donde se crea este objeto (como establecer la ruta de este objeto en otro lugar) o cómo puedo implementar este objeto antes, por lo que se instala con mi aplicación? – Akku
@Tim, no creo que pueda influir en dónde se crea. Lo hace automáticamente el sistema de compilación. Para implementarlo, simplemente cópielo en la carpeta de destino de su aplicación. – JaredPar
Gracias! Esto es exactamente lo que tenía que hacer :-) – Akku