Skip to content

Commit

Permalink
Updated few ATF files
Browse files Browse the repository at this point in the history
  • Loading branch information
abeckus committed Jul 29, 2014
1 parent 5c9e0a0 commit d9ae991
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
27 changes: 1 addition & 26 deletions ATF/Framework/Atf.Core/AtfUsageLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private static void _SendAtfUsageInfo(object unusedState)
bool appIs64Bit = (IntPtr.Size == 8);
string osVersion = GetOSFullName();
string clrVersion = Environment.Version.ToString();
int physicalMb = GetPhysicalMemoryMB();
int physicalMb = Kernel32.GetPhysicalMemoryMB();

// Analyze all loaded assemblies
StringBuilder loadedAssemblies = new StringBuilder();
Expand Down Expand Up @@ -171,31 +171,6 @@ private static void ParseAssemblyName(string fullName, out string name, out stri
version = parts[1].Trim();
}

[StructLayout(LayoutKind.Sequential)]
private class MEMORYSTATUSEX
{
public uint dwLength = 64;
public uint dwMemoryLoad;
public ulong ullTotalPhys; //The amount of actual physical memory, in bytes.
public ulong ullAvailPhys;
public ulong ullTotalPageFile;
public ulong ullAvailPageFile;
public ulong ullTotalVirtual;
public ulong ullAvailVirtual;
public ulong ullAvailExtendedVirtual;
}

[DllImport("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool GlobalMemoryStatusEx(MEMORYSTATUSEX lpBuffer);

private static int GetPhysicalMemoryMB()
{
// Available from Windows 2000 and onward; i.e., Environment.OSVersion.Version.Major >= 5 .
var memoryStatus = new MEMORYSTATUSEX();
GlobalMemoryStatusEx(memoryStatus);
return (int)(memoryStatus.ullTotalPhys / (1024 * 1024));// convert bytes to megabytes
}

private static string GetInstalledVisualStudioVersions()
{
var versionSet = new HashSet<string>();
Expand Down
26 changes: 26 additions & 0 deletions ATF/Framework/Atf.Core/Kernel32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,32 @@ public static extern uint QueryDosDeviceW(
[In] [MarshalAsAttribute(UnmanagedType.LPWStr)] string lpDeviceName,
[Out] [MarshalAsAttribute(UnmanagedType.LPWStr)] System.Text.StringBuilder lpTargetPath,
uint ucchMax);


[StructLayout(LayoutKind.Sequential)]
private class MEMORYSTATUSEX
{
public uint dwLength = 64;
public uint dwMemoryLoad;
public ulong ullTotalPhys; //The amount of actual physical memory, in bytes.
public ulong ullAvailPhys;
public ulong ullTotalPageFile;
public ulong ullAvailPageFile;
public ulong ullTotalVirtual;
public ulong ullAvailVirtual;
public ulong ullAvailExtendedVirtual;
}

[DllImport("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool GlobalMemoryStatusEx(MEMORYSTATUSEX lpBuffer);

public static int GetPhysicalMemoryMB()
{
// Available from Windows 2000 and onward; i.e., Environment.OSVersion.Version.Major >= 5 .
var memoryStatus = new MEMORYSTATUSEX();
GlobalMemoryStatusEx(memoryStatus);
return (int)(memoryStatus.ullTotalPhys / (1024 * 1024));// convert bytes to megabytes
}
}
}

0 comments on commit d9ae991

Please sign in to comment.