Now fetching some of our Sound Graph DLL function pointers.
1.1 --- a/GUI/MainForm.cs Sun Feb 03 18:01:50 2013 +0100
1.2 +++ b/GUI/MainForm.cs Sun Feb 03 19:06:01 2013 +0100
1.3 @@ -18,6 +18,7 @@
1.4 using System.IO;
1.5 using System.Reflection;
1.6 using System.Windows.Forms;
1.7 +using System.Windows;
1.8 using Aga.Controls.Tree;
1.9 using Aga.Controls.Tree.NodeControls;
1.10 using OpenHardwareMonitor.Hardware;
1.11 @@ -131,7 +132,19 @@
1.12 systemTray.HideShowCommand += hideShowClick;
1.13 systemTray.ExitCommand += exitClick;
1.14
1.15 - soundGraphDisplay = new SoundGraphDisplay(computer, settings, unitManager);
1.16 + soundGraphDisplay = new SoundGraphDisplay(computer, settings, unitManager);
1.17 + if (soundGraphDisplay.IsDllLoaded)
1.18 + {
1.19 + //Try init
1.20 + //NativeWindow window;
1.21 +
1.22 +
1.23 + //= Window.GetWindow(this);
1.24 + //var wih = new WindowInteropHelper(window);
1.25 + //IntPtr hWnd = wih.Handle;
1.26 + }
1.27 +
1.28 +
1.29
1.30 int p = (int)Environment.OSVersion.Platform;
1.31 if ((p == 4) || (p == 128)) { // Unix
2.1 --- a/GUI/SoundGraphDisplay.cs Sun Feb 03 18:01:50 2013 +0100
2.2 +++ b/GUI/SoundGraphDisplay.cs Sun Feb 03 19:06:01 2013 +0100
2.3 @@ -46,6 +46,127 @@
2.4 public static extern bool FreeLibrary(IntPtr hModule);
2.5 }
2.6
2.7 +/**
2.8 +Definitions taken from public Sound Graph APIs.
2.9 + */
2.10 +static class SoundGraph
2.11 +{
2.12 + /**DSPResult
2.13 + @brief These enumeration values represent the returned result for iMON Display API function calls.\n
2.14 + All iMON Display API function calls return one of this result values.\n
2.15 + For meaning of each result, refer the comment of each line below*/
2.16 + public enum DSPResult : uint
2.17 + {
2.18 + DSP_SUCCEEDED = 0, //// Function Call Succeeded Without Error
2.19 + DSP_E_FAIL, //// Unspecified Failure
2.20 + DSP_E_OUTOFMEMORY, //// Failed to Allocate Necessary Memory
2.21 + DSP_E_INVALIDARG, //// One or More Arguments Are Not Valid
2.22 + DSP_E_NOT_INITED, //// API is Not Initialized
2.23 + DSP_E_POINTER, //// Pointer is Not Valid
2.24 +
2.25 + DSP_S_INITED = 0x1000, //// API is Initialized
2.26 + DSP_S_NOT_INITED, //// API is Not Initialized
2.27 + DSP_S_IN_PLUGIN_MODE, //// API Can Control iMON Display (Display Plug-in Mode)
2.28 + DSP_S_NOT_IN_PLUGIN_MODE, //// API Can't Control iMON Display
2.29 + };
2.30 +
2.31 +
2.32 + /**DSPNInitResult
2.33 + @brief These enumeration values represent the result status for requesting Display Plug-in Mode to iMON.\n
2.34 + iMON Display API notifies one of this result values to the caller application after requesting Display Plug-in Mode to iMON.\n
2.35 + For more information, refer the comment of each line below*/
2.36 + public enum DSPNInitResult : uint
2.37 + {
2.38 + DSPN_SUCCEEDED = 0, //// Display Plug-in Mode is Initialized Successfully
2.39 + DSPN_ERR_IN_USED = 0x0100, //// Display Plug-in is Already Used by Other Application
2.40 + DSPN_ERR_HW_DISCONNECTED, //// iMON HW is Not Connected
2.41 + DSPN_ERR_NOT_SUPPORTED_HW, //// The Connected iMON HW doesn't Support Display Plug-in
2.42 + DSPN_ERR_PLUGIN_DISABLED, //// Display Plug-in Mode Option is Disabled
2.43 + DSPN_ERR_IMON_NO_REPLY, //// The Latest iMON is Not Installed or iMON Not Running
2.44 + DSPN_ERR_UNKNOWN = 0x0200, //// Unknown Failure
2.45 + };
2.46 +
2.47 +
2.48 + /**DSPType
2.49 + @brief These enumeration values represent display type.\n
2.50 + Currently iMON Display API supports VFD and LCD products.*/
2.51 + public enum DSPType : uint
2.52 + {
2.53 + DSPN_DSP_NONE = 0,
2.54 + DSPN_DSP_VFD = 0x01, //// VFD products
2.55 + DSPN_DSP_LCD = 0x02, //// LCD products
2.56 + };
2.57 +
2.58 +
2.59 + /**DSPNotifyCode
2.60 + @brief These enumeration values represent the notification codes.\n
2.61 + iMON Display API will send or post message to the caller application.\n
2.62 + The caller application should assign the message and the winodw handle to receivce message with IMON_Display_Init fucntion.\n
2.63 + These enumeration values are used with WPARAM parameter of the message.\n
2.64 + For more information, see the explanation of each notification code below*/
2.65 + public enum DSPNotifyCode : uint
2.66 + {
2.67 + /**DSPNM_PLUGIN_SUCCEED
2.68 + @brief When API succeeds to get the control for the display, API will post caller-specified message with DSPNM_PLUGIN_SUCCEED as WPARAM parameter.\n
2.69 + LPARAM represents DSPType. This value can be 0x01 (VFD), 0x02 (LCD) or 0x03 (VFD+LCD).*/
2.70 + DSPNM_PLUGIN_SUCCEED = 0,
2.71 +
2.72 + /**DSPNM_PLUGIN_FAILED
2.73 + @brief When API fails to get the control for the display, API will post caller-specified message with DSPNM_PLUGIN_FAILED as WPARAM parameter.\n
2.74 + LPARAM represents error code with DSPNResult.*/
2.75 + DSPNM_PLUGIN_FAILED,
2.76 +
2.77 + /**DSPNM_IMON_RESTARTED
2.78 + @brief When iMON starts, API will post caller-specified message with DSPNM_IMON_RESTARTED as WPARAM parameter.\n
2.79 + LPARAM represents DSPType. This value can be 0 (No Display), 0x01 (VFD), 0x02 (LCD) or 0x03 (VFD+LCD).*/
2.80 + DSPNM_IMON_RESTARTED,
2.81 +
2.82 + /**DSPNM_IMON_CLOSED
2.83 + @brief When iMON closed, API will post caller-specified message with DSPNM_IMON_CLOSED as WPARAM parameter.\n
2.84 + LPARAM is not used.*/
2.85 + DSPNM_IMON_CLOSED,
2.86 +
2.87 + /**DSPNM_HW_CONNECTED
2.88 + @brief When iMON HW newly connected, API will post caller-specified message with DSPNM_HW_CONNECTED as WPARAM parameter.\n
2.89 + LPARAM represents DSPType. This value can be 0 (No Display), 0x01 (VFD), 0x02 (LCD) or 0x03 (VFD+LCD).*/
2.90 + DSPNM_HW_CONNECTED,
2.91 +
2.92 + /**DSPNM_HW_DISCONNECTED
2.93 + @brief When iMON HW disconnected, API will post caller-specified message with DSPNM_HW_DISCONNECTED as WPARAM parameter.\n
2.94 + LPARAM is DSPNResult value, DSPN_ERR_HW_DISCONNECTED.*/
2.95 + DSPNM_HW_DISCONNECTED,
2.96 +
2.97 +
2.98 + /**DSPNM_LCD_TEXT_SCROLL_DONE
2.99 + @brief When iMON LCD finishes scrolling Text, API will post caller-specified message with DSPNM_LCD_TEXT_SCROLL_DONE as WPARAM parameter.\n
2.100 + The caller application may need to know when text scroll is finished, for sending next text.\n
2.101 + LPARAM is not used.*/
2.102 + DSPNM_LCD_TEXT_SCROLL_DONE = 0x1000,
2.103 + };
2.104 +
2.105 + /// Functions
2.106 + [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
2.107 + public delegate DSPResult IMON_Display_Uninit();
2.108 +
2.109 + [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
2.110 + public delegate DSPResult IMON_Display_Init(IntPtr hwndNoti, uint uMsgNotification);
2.111 +
2.112 + [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
2.113 + public delegate DSPResult IMON_Display_IsInited();
2.114 +
2.115 + [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
2.116 + public delegate DSPResult IMON_Display_IsPluginModeEnabled();
2.117 +
2.118 + [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
2.119 + public delegate DSPResult IMON_Display_SetVfdText(
2.120 + [MarshalAs(UnmanagedType.LPWStr)] string lpsz1stLine,
2.121 + [MarshalAs(UnmanagedType.LPWStr)] string lpsz2ndLine);
2.122 +
2.123 + //IMONDSPAPI DSPResult IMON_Display_SetVfdText(LPCTSTR lpsz1stLine, LPCTSTR lpsz2ndLine);
2.124 +
2.125 +}
2.126 +
2.127 +
2.128
2.129 namespace OpenHardwareMonitor.GUI
2.130 {
2.131 @@ -58,6 +179,11 @@
2.132 //private bool mainIconEnabled = false;
2.133 //private NotifyIconAdv mainIcon;
2.134 IntPtr iSoundGraphDll;
2.135 + SoundGraph.IMON_Display_Uninit iIMON_Display_Uninit;
2.136 + SoundGraph.IMON_Display_Init iIMON_Display_Init;
2.137 + SoundGraph.IMON_Display_IsInited iIMON_Display_IsInited;
2.138 + SoundGraph.IMON_Display_IsPluginModeEnabled iIMON_Display_IsPluginModeEnabled;
2.139 + SoundGraph.IMON_Display_SetVfdText iIMON_Display_SetVfdText;
2.140
2.141 public SoundGraphDisplay(IComputer computer, PersistentSettings settings,
2.142 UnitManager unitManager)
2.143 @@ -82,9 +208,24 @@
2.144 else
2.145 {
2.146 Console.Write(@"iMON: DLL loaded.");
2.147 + //Gather our function pointers
2.148 + //TODO: Check returned pointers for validity
2.149 + IntPtr functionPointer = NativeMethods.GetProcAddress(iSoundGraphDll, "IMON_Display_Uninit");
2.150 + iIMON_Display_Uninit = (SoundGraph.IMON_Display_Uninit)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(SoundGraph.IMON_Display_Uninit));
2.151 +
2.152 + functionPointer = NativeMethods.GetProcAddress(iSoundGraphDll, "IMON_Display_Init");
2.153 + iIMON_Display_Init = (SoundGraph.IMON_Display_Init)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(SoundGraph.IMON_Display_Init));
2.154 +
2.155 + functionPointer = NativeMethods.GetProcAddress(iSoundGraphDll, "IMON_Display_IsInited");
2.156 + iIMON_Display_IsInited = (SoundGraph.IMON_Display_IsInited)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(SoundGraph.IMON_Display_IsInited));
2.157 +
2.158 + functionPointer = NativeMethods.GetProcAddress(iSoundGraphDll, "IMON_Display_IsPluginModeEnabled");
2.159 + iIMON_Display_IsPluginModeEnabled = (SoundGraph.IMON_Display_IsPluginModeEnabled)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(SoundGraph.IMON_Display_IsPluginModeEnabled));
2.160 +
2.161 + functionPointer = NativeMethods.GetProcAddress(iSoundGraphDll, "IMON_Display_SetVfdText");
2.162 + iIMON_Display_SetVfdText = (SoundGraph.IMON_Display_SetVfdText)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(SoundGraph.IMON_Display_SetVfdText));
2.163 +
2.164 }
2.165 -
2.166 -
2.167 }
2.168
2.169 private void HardwareRemoved(IHardware hardware)
2.170 @@ -204,6 +345,21 @@
2.171 */
2.172 }
2.173
2.174 + private void Init(IntPtr aHWND)
2.175 + {
2.176 + //iIMON_Display_Init
2.177 + }
2.178 +
2.179 + private void Uninit()
2.180 + {
2.181 + iIMON_Display_Uninit();
2.182 + }
2.183 +
2.184 + private void SetText(string aUpperLine, string aLowerLine)
2.185 + {
2.186 +
2.187 + }
2.188 +
2.189 /*
2.190 public bool IsMainIconEnabled
2.191 {
2.192 @@ -217,5 +373,11 @@
2.193 }
2.194 }
2.195 }*/
2.196 +
2.197 +
2.198 + public bool IsDllLoaded
2.199 + {
2.200 + get { return iSoundGraphDll!=IntPtr.Zero; }
2.201 + }
2.202 }
2.203 }