public static bool TShellExecute(string FileName) { int nSize = FileName.Length * 2 + 2; IntPtr pData = LocalAlloc(0x40, nSize); Marshal.Copy(Encoding.Unicode.GetBytes(FileName), 0, pData, nSize - 2); SHELLEXECUTEEX see = new SHELLEXECUTEEX(); see.cbSize = 60; see.dwHotKey = 0; see.fMask = 0; see.hIcon = IntPtr.Zero; see.hInstApp = IntPtr.Zero; see.hProcess = IntPtr.Zero;; see.lpClass = IntPtr.Zero; see.lpDirectory = IntPtr.Zero; see.lpIDList = IntPtr.Zero; see.lpParameters = IntPtr.Zero; see.lpVerb = IntPtr.Zero; see.nShow = 0; see.lpFile = pData; if (ShellExecuteEx(see) == 0) { LocalFree(pData); return(false); } //Waitforsingleobject LocalFree(pData); return(true); }
extern static public int ShellExecuteEx(SHELLEXECUTEEX ex);