Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2007-04-17 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:50 +0300
commita145bfc7cf17f7bbcfae8f0064333c8ea75b455c (patch)
tree4ea458c9f35956fe080562989a702ea8c9af4b90 /CPP/Windows
parentd9666cf046a8453b33b3e2fbf4d82295a9f87df3 (diff)
4.45 beta
Diffstat (limited to 'CPP/Windows')
-rwxr-xr-xCPP/Windows/ResourceString.cpp19
-rwxr-xr-xCPP/Windows/ResourceString.h6
-rwxr-xr-xCPP/Windows/System.h27
3 files changed, 46 insertions, 6 deletions
diff --git a/CPP/Windows/ResourceString.cpp b/CPP/Windows/ResourceString.cpp
index 48dd4936..42cc477e 100755
--- a/CPP/Windows/ResourceString.cpp
+++ b/CPP/Windows/ResourceString.cpp
@@ -14,7 +14,7 @@ extern bool g_IsNT;
namespace NWindows {
-CSysString MyLoadString(UINT resourceID)
+CSysString MyLoadString(HINSTANCE hInstance, UINT resourceID)
{
CSysString s;
int size = 256;
@@ -22,15 +22,20 @@ CSysString MyLoadString(UINT resourceID)
do
{
size += 256;
- len = ::LoadString(g_hInstance, resourceID, s.GetBuffer(size - 1), size);
+ len = ::LoadString(hInstance, resourceID, s.GetBuffer(size - 1), size);
}
while (size - len <= 1);
s.ReleaseBuffer();
return s;
}
+CSysString MyLoadString(UINT resourceID)
+{
+ return MyLoadString(g_hInstance, resourceID);
+}
+
#ifndef _UNICODE
-UString MyLoadStringW(UINT resourceID)
+UString MyLoadStringW(HINSTANCE hInstance, UINT resourceID)
{
if (g_IsNT)
{
@@ -40,7 +45,7 @@ UString MyLoadStringW(UINT resourceID)
do
{
size += 256;
- len = ::LoadStringW(g_hInstance, resourceID, s.GetBuffer(size - 1), size);
+ len = ::LoadStringW(hInstance, resourceID, s.GetBuffer(size - 1), size);
}
while (size - len <= 1);
s.ReleaseBuffer();
@@ -48,6 +53,12 @@ UString MyLoadStringW(UINT resourceID)
}
return GetUnicodeString(MyLoadString(resourceID));
}
+
+UString MyLoadStringW(UINT resourceID)
+{
+ return MyLoadStringW(g_hInstance, resourceID);
+}
+
#endif
}
diff --git a/CPP/Windows/ResourceString.h b/CPP/Windows/ResourceString.h
index a74f925d..1bfc88ab 100755
--- a/CPP/Windows/ResourceString.h
+++ b/CPP/Windows/ResourceString.h
@@ -7,11 +7,13 @@
namespace NWindows {
+CSysString MyLoadString(HINSTANCE hInstance, UINT resourceID);
CSysString MyLoadString(UINT resourceID);
#ifdef _UNICODE
-inline UString MyLoadStringW(UINT resourceID)
- { return MyLoadString(resourceID); }
+inline UString MyLoadStringW(HINSTANCE hInstance, UINT resourceID) { return MyLoadString(hInstance, resourceID); }
+inline UString MyLoadStringW(UINT resourceID) { return MyLoadString(resourceID); }
#else
+UString MyLoadStringW(HINSTANCE hInstance, UINT resourceID);
UString MyLoadStringW(UINT resourceID);
#endif
diff --git a/CPP/Windows/System.h b/CPP/Windows/System.h
index e1a5abac..a81aba98 100755
--- a/CPP/Windows/System.h
+++ b/CPP/Windows/System.h
@@ -15,6 +15,33 @@ inline UInt32 GetNumberOfProcessors()
return (UInt32)systemInfo.dwNumberOfProcessors;
}
+#ifndef _WIN64
+typedef BOOL (WINAPI *GlobalMemoryStatusExP)(LPMEMORYSTATUSEX lpBuffer);
+#endif
+
+inline UInt64 GetRamSize()
+{
+ MEMORYSTATUSEX stat;
+ stat.dwLength = sizeof(stat);
+ #ifdef _WIN64
+ if (!::GlobalMemoryStatusEx(&stat))
+ return 0;
+ return stat.ullTotalPhys;
+ #else
+ GlobalMemoryStatusExP globalMemoryStatusEx = (GlobalMemoryStatusExP)
+ ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
+ "GlobalMemoryStatusEx");
+ if (globalMemoryStatusEx != 0)
+ if (globalMemoryStatusEx(&stat))
+ return stat.ullTotalPhys;
+ {
+ MEMORYSTATUS stat;
+ stat.dwLength = sizeof(stat);
+ GlobalMemoryStatus(&stat);
+ return stat.dwTotalPhys;
+ }
+ #endif
+}
}}