【发布时间】:2014-01-08 02:00:57
【问题描述】:
我有一个 C# 程序。该程序创建一个 Adobe Reader 进程并打印一个PDF 文档。它在 Windows XP 中运行良好,但在 Windows 7 中无法运行。我检查了 AcroRd32.exe 路径在 Windows 7 中是否正确。FindWindow 方法在 Windows 7 中始终返回 0。
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
[DllImport("User32.dll")]
public static extern IntPtr FindWindow(string ClassN, string WindN);
[DllImport("user32.dll", EntryPoint = "SendMessageA")]
private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("shell32.dll ")]
public static extern int ShellExecute(IntPtr hwnd, string lpszOp, string lpszFile, string lpszParams, string lpszDir, int FsShowCmd);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern uint WinExec(string lpCmdLine, uint uCmdShow);
public bool isAcrobatExsists(string acrobatLoc)
{
IntPtr currentHandle = getWindowHandlerByClass("AcrobatSDIWindow");
if (currentHandle != IntPtr.Zero)
{
return true;
}
return false;
}
private static IntPtr getWindowHandlerByClass(string className)
{
IntPtr currentHandle = FindWindow(className, null);
return currentHandle;
}
private static IntPtr getWindowHandlerByName(string appName)
{
IntPtr currentHandle = FindWindow(null, appName);
return currentHandle;
}
【问题讨论】:
-
我试过了。它仍然返回 0。
标签: c# pdf printing windows-7 findwindow