[DllImport("winspool.drv", SetLastError = true, CharSet = CharSet.Auto)]
private static extern Int32 AddMonitor(String pName, UInt32 Level, ref MONITOR_INFO_2 pMonitors);
Do you know one? Please contribute it!
None.
Please add some!
String sErrorTitle="Installing monitor";
String szMonitor="MyMonitor";
MONITOR_INFO_2 mi2 = new MONITOR_INFO_2();
mi2.pName = szMonitor;
mi2.pEnvironment = null;
mi2.pDLLName = "mymon.dll";
try
{
if (AddMonitor(null, 2, ref mi2) == 0)
{
string errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message;
MessageBox.Show(String.Format("Adding the monitor failed.\n\nError: {0}", errorMessage), sErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
catch (Exception e)
{
MessageBox.Show(String.Format("Adding the monitor failed:\n\nException: {0}", e.ToString()), sErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
}