Ejemplo n.º 1
0
		internal extern static int ShellExecuteExCE( SHELLEXECUTEEX ex );
Ejemplo n.º 2
0
		public static IntPtr ShellExecute(string FileName, string Parameters)
		{
			int nSize;
			SHELLEXECUTEEX see;
			IntPtr pFile;
			IntPtr pParams;

			see = new SHELLEXECUTEEX();

			nSize = FileName.Length * 2 + 2;
			pFile = LocalAlloc(MemoryAllocFlags.LPtr, nSize);
			Marshal.Copy(Encoding.Unicode.GetBytes(FileName), 0, pFile, nSize - 2);

			nSize = Parameters.Length * 2 + 2;
			pParams = LocalAlloc(MemoryAllocFlags.LPtr, nSize);
			Marshal.Copy(Encoding.Unicode.GetBytes(Parameters), 0, pParams, nSize - 2);
			
			see.lpFile = pFile;
			see.lpParameters = pParams;
			
			if(ShellExecuteExCE(see) == 0)
			{
				throw new WinAPIException("Cannot Execute File");
			}

			LocalFreeCE(pFile);
			LocalFreeCE(pParams);
		
			return see.hProcess;
		}