【发布时间】:2011-04-17 04:16:33
【问题描述】:
我正在制作图片上传器(将图片上传到图片托管网站),但在传递参数时遇到了一些问题(图片位置到已运行的应用程序)
- 首先假设 MyApp.exe 一直在运行
- 每当我右键单击图像时,我都会在默认的 Windows 上下文菜单中添加一个项目,显示“上传图像”。
- 单击该按钮后,需要将位置传递给已运行的应用程序。
我的程序.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 类没有可见的表单,只有一个托盘图标存在,因为不需要表单。
我可以就如何做到这一点获得任何帮助吗?
【问题讨论】: