我正在制作一个图片上传器(将图片上传到图像托管网站),但是在传递参数(图像位置到已运行的应用程序)时遇到了一些问题。
- 首先,假设MyApp.exe始终在运行。
- 每当我右键单击图像时,在默认的Windows上下文菜单中添加了一个项目,名为“上传图像”。
- 点击该项目后,需要将位置传递给已经运行的应用程序。
我的program.cs:
static class Program
{
[DllImport("user32.dll")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, UIntPtr
wParam, IntPtr lParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern uint RegisterWindowMessage(string lpString);
[STAThread]
static void Main(params string[] Arguments)
{
if (Arguments.Length > 0)
{
//This means that the the upload item in the context menu is clicked
//Here the method "uploadImage(string location)"
//of the running application must be ran
}
else
{
//just start the application
Application.Run(new ControlPanel());
}
}
}
请注意,ControlPanel类没有可见的窗体,只有托盘图标存在,因为不需要窗体。我能得到如何做到这一点的任何帮助吗?