public static UInt32 LSAMgmtQueryLsaMetrics_1(string serverName, out LsaMetricPack_1 metrics) { UInt32 result = 0; string functionName = "LSAMgmtAPI.LSAMgmtQueryLsaMetrics_1"; IntPtr pMetrics = IntPtr.Zero; metrics = new LsaMetricPack_1(); try { Logger.Log(String.Format( "{0}(serverName={1}) called", functionName, serverName), Logger.LSAMgmtLogLevel); result = PrivateLSAMgmtAPI.LWMGMTQueryLsaMetrics_1( serverName, out pMetrics); if (result != 0) { return(result); } if (pMetrics.Equals(IntPtr.Zero)) { throw new Exception("Failed to read metrics; null handle returned"); } metrics = (LsaMetricPack_1)Marshal.PtrToStructure(pMetrics, typeof(LsaMetricPack_1)); Logger.Log(String.Format( "{0}: result={1}", functionName, result), Logger.LSAMgmtLogLevel); int freeSuccess = (int)PrivateLSAMgmtAPI.LWMGMTFreeLsaMetrics_1(pMetrics); if (freeSuccess != 0) { Logger.Log(String.Format( "WARNING: PrivateLSAMgmtAPI.LWMGMTFreeLsaMetrics_1 reports failure! [code={0}]", freeSuccess), Logger.LogLevel.Panic); } } catch (Exception ex) { Logger.LogException(functionName, ex); if (result == 0) { result = 0xFFFFFFFF; } } return(result); }