Merge pull request #793 from jpcima/host-info
Add host info for LV2, and in general
This commit is contained in:
commit
3c00c8b750
4 changed files with 42 additions and 0 deletions
|
|
@ -161,9 +161,12 @@ SAboutDialog::SAboutDialog(const CRect& bounds)
|
|||
|
||||
///
|
||||
sysInfoTemplate_ = lblSysInfoValue_->getText();
|
||||
sysInfoVariables_["%Pluginformat%"] = {};
|
||||
sysInfoVariables_["%HostOS%"] = getOperatingSystemName();
|
||||
sysInfoVariables_["%HostCPU%"] = getProcessorName();
|
||||
sysInfoVariables_["%HostBits%"] = std::to_string(8 * sizeof(void*));
|
||||
sysInfoVariables_["%HostProgram%"] = getCurrentProcessName();
|
||||
updateSysInfo();
|
||||
}
|
||||
|
||||
void SAboutDialog::setPluginFormat(const std::string& pluginFormat)
|
||||
|
|
|
|||
|
|
@ -137,6 +137,24 @@ std::string getProcessorName()
|
|||
std::unique_ptr<char[]> valueUTF8(stringToUTF8(valueW.get()));
|
||||
return valueUTF8.get();
|
||||
}
|
||||
|
||||
std::string getCurrentProcessName()
|
||||
{
|
||||
DWORD size = 32768;
|
||||
std::unique_ptr<WCHAR[]> buffer(new WCHAR[size]());
|
||||
|
||||
if (!GetModuleFileNameW(nullptr, buffer.get(), size))
|
||||
return {};
|
||||
|
||||
buffer[size - 1] = L'\0';
|
||||
const WCHAR* name = buffer.get();
|
||||
|
||||
if (const WCHAR* pos = wcsrchr(name, L'\\'))
|
||||
name = pos + 1;
|
||||
|
||||
std::unique_ptr<char[]> nameUTF8(stringToUTF8(name));
|
||||
return nameUTF8.get();
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
// implemented in NativeHelpers.mm
|
||||
#else
|
||||
|
|
@ -151,6 +169,7 @@ std::string getProcessorName()
|
|||
#include <cstring>
|
||||
#include <cerrno>
|
||||
extern "C" { extern char **environ; }
|
||||
extern "C" { extern char *__progname; }
|
||||
|
||||
static bool openFileByMimeType(const char *filename, const char *mimetype)
|
||||
{
|
||||
|
|
@ -296,4 +315,12 @@ std::string getProcessorName()
|
|||
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string getCurrentProcessName()
|
||||
{
|
||||
const char* name = __progname;
|
||||
if (!name)
|
||||
return std::string();
|
||||
return name;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ bool openURLWithExternalProgram(const char *url);
|
|||
bool askQuestion(const char *text);
|
||||
std::string getOperatingSystemName();
|
||||
std::string getProcessorName();
|
||||
std::string getCurrentProcessName();
|
||||
|
||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||
bool isZenityAvailable();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
|
||||
static bool openFileWithApplication(const char *fileName, NSString *application)
|
||||
|
|
@ -78,4 +79,14 @@ std::string getProcessorName()
|
|||
|
||||
return std::string(nameBuf, size);
|
||||
}
|
||||
|
||||
std::string getCurrentProcessName()
|
||||
{
|
||||
kinfo_proc proc {};
|
||||
size_t size = sizeof(kinfo_proc);
|
||||
int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, int(getpid()) };
|
||||
if (sysctl(name, 4, &proc, &size, nullptr, 0) == -1)
|
||||
return {};
|
||||
return proc.kp_proc.p_comm;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue