public static void Initialize() { try { string dirPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string envVariable = Path.Combine(dirPath, "presets"); Environment.SetEnvironmentVariable("FFMPEG_DATADIR", envVariable); int ret = InitializeHelper( Path.Combine(dirPath, "log_helper_error.txt"), Path.Combine(dirPath, "log_helper_out.txt")); } catch (Exception ex) { StatusLog.CreateExceptionEntry(ex); throw; } }
static IntPtr RunProcess(string[] args, out int size) { size = 0; try { using (MemoryStream ms = new MemoryStream()) { ms.WriteByte((byte)args.Length); var convertedArgs = from x in args select x; foreach (string s in convertedArgs) { ms.WriteByte((byte)s.Length); } foreach (string s in convertedArgs) { byte[] b = (from x in s.ToCharArray() select(byte) x).ToArray(); ms.Write(b, 0, b.Length); } ms.Position = 0; byte[] buffer = ms.GetBuffer(); size = buffer.Length; IntPtr ptr = Marshal.AllocHGlobal(buffer.Length); Marshal.Copy(buffer, 0, ptr, buffer.Length); return(ptr); } } catch (Exception ex) { StatusLog.CreateExceptionEntry(ex); return(IntPtr.Zero); } }