Si inizia inserendo la chiamata alla funzione esterna:
C#
using System.Runtime.InteropServices;
[DllImport("Shell32.dll")]
protected static extern int FindExecutable(
string lpFile, string lpDirectory,StringBuilder lpResult);
Inserire una funzione “wrapper” a cui passare il nome del file da controllare (esempio c:\myfile.txt) che restituisce una stringa contenente il nome dell’applicazione che la apre.
C#
public static string FindAssociatedApplication(string pFileName)
{
StringBuilder NomeEseguibile = new StringBuilder(1024);
if (FindExecutable(pFileName,String.Empty, NomeEseguibile) > 32)
return NomeEseguibile.ToString();
else
return "";
}
Nessun commento:
Posta un commento