トップ回答者
プリンタプロパティ画面を閉じる方法

質問
回答
-
Win32API を使うと下記のようなコードで閉じることができると思います。
using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { [DllImport("user32.dll")] static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll")] static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { IntPtr hPrinterPropertyWindow = FindWindow(null, "My Printerのプロパティ"); SendMessage(hPrinterPropertyWindow, 0x0010 /*WM_CLOSE*/, 0, 0); } } }
- 回答としてマーク y-ske 2017年10月18日 0:20
すべての返信
-
- 回答の候補に設定 立花楓Microsoft employee, Moderator 2017年10月16日 2:47
-
Win32API を使うと下記のようなコードで閉じることができると思います。
using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { [DllImport("user32.dll")] static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll")] static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { IntPtr hPrinterPropertyWindow = FindWindow(null, "My Printerのプロパティ"); SendMessage(hPrinterPropertyWindow, 0x0010 /*WM_CLOSE*/, 0, 0); } } }
- 回答としてマーク y-ske 2017年10月18日 0:20