Sony Vegas 托管的 CLR 似乎不支持 NamedPipeClientStream。我通过使用 Windows 中的消息系统实现了相同的行为。这是我在 Sony Vegas Script 中使用的代码
public static class SonyVegasWindowMessageHelper
{
private const int WM_USER = 0x400;
private const int WM_COPYDATA = 0x4A;
private const int VIDEO_RENDERED = 52;
[DllImport("user32.dll")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
private static extern bool SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, ref COPYDATASTRUCT lParam);
public static void SendMessage(string message)
{
IntPtr window = FindWindow(null, "Youtube Video Uploader");
if (window != IntPtr.Zero)
{
byte[] data = Encoding.Default.GetBytes(message);
COPYDATASTRUCT str = new COPYDATASTRUCT();
str.CbData = data.Length + 1;
str.DwData = (IntPtr)VIDEO_RENDERED;
str.LpData = message;
SendMessage(window, WM_COPYDATA, IntPtr.Zero, ref str);
}
}
private struct COPYDATASTRUCT
{
public IntPtr DwData;
public int CbData;
[MarshalAs(UnmanagedType.LPStr)]
public string LpData;
}
}
使用 SendMessage,您可以将任何您想要的消息发送到其他应用程序。