Hola
bueno tenia problema implementando un codigo en Win XP en Win 7 es funcional
me salia este error
"Unable to cast COM object of type 'System.__ComObject' to interface type 'Shell32.Shell'."
sabia que era algun error sobre Shell32.Shell que lo usaba en el codigo , me puse a buscar en google
a ver la solucion y encontre este sitio que me resolvo mi problema
http://nerdynotes.blogspot.com/2008/06/vbnet-shell32-code-compiled-on-vista.htmlla solucion fue usar Reflection (cargando Objects en Runtime)
codigo antes :
static string GetShortcutTargetFile(string shortcutFilename)
{
string pathOnly = System.IO.Path.GetDirectoryName(shortcutFilename);
string filenameOnly = System.IO.Path.GetFileName(shortcutFilename);
Shell32.Shell shell = new Shell32.Shell();
Shell32.Folder folder = shell.NameSpace(pathOnly);
Shell32.FolderItem folderItem = folder.ParseName(filenameOnly);
if (File.Exists(((Shell32.ShellLinkObject)folderItem.GetLink).Path))
if (folderItem != null)
{
if (((Shell32.ShellLinkObject)folderItem.GetLink).Path.ToString().IndexOf("windows", 0, StringComparison.CurrentCultureIgnoreCase) != -1)
{
return "";
}
return ((Shell32.ShellLinkObject)folderItem.GetLink).Path;
}
return "";
}
codigo despues :
static string GetShortcutTargetFile(string shortcutFilename)
{
string pathOnly = System.IO.Path.GetDirectoryName(shortcutFilename);
string filenameOnly = System.IO.Path.GetFileName(shortcutFilename);
//Shell32.Shell shell = new Shell32.Shell();
var t = Type.GetTypeFromProgID("Shell.Application");
dynamic shell = Activator.CreateInstance(t);
//Shell32.Folder folder = shell.NameSpace(pathOnly);
var folder = shell.NameSpace(pathOnly);
var folderItem = folder.ParseName(filenameOnly);
var t1 = folderItem.GetLink;
string t1str = t1.Path;
if (File.Exists(t1str))
if (folderItem != null)
{
if (t1str.IndexOf("windows", 0, StringComparison.CurrentCultureIgnoreCase) != -1)
{
return "";
}
return t1str;
}
return "";
}
bueno espero que sea util a alguien
Saludos