#if defined(__WXWINCE__)
// TODO-CE
return false;
-#elif defined(__WIN32__) && !defined(__WXMICROWIN__)
+#else
DWORD nSize = maxSize;
if ( !::GetComputerName(buf, &nSize) )
{
}
return true;
-#else
- wxChar *sysname;
- const wxChar *default_host = wxT("noname");
-
- if ((sysname = wxGetenv(wxT("SYSTEM_NAME"))) == NULL) {
- GetProfileString(WX_SECTION, eHOSTNAME, default_host, buf, maxSize - 1);
- } else
- wxStrncpy(buf, sysname, maxSize - 1);
- buf[maxSize] = wxT('\0');
- return *buf ? true : false;
#endif
}
if ( !host.empty() )
{
- wxStrncpy(buf, host, maxSize);
+ wxStrlcpy(buf, host.c_str(), maxSize);
return true;
}
#if defined(__WXWINCE__)
// TODO-CE
return false;
-#elif defined(__WIN32__) && !defined(__WXMICROWIN__)
+#else
DWORD nSize = maxSize;
if ( ::GetUserName(buf, &nSize) == 0 )
{
}
return true;
-#else // __WXMICROWIN__
- wxChar *user;
- const wxChar *default_id = wxT("anonymous");
-
- // Can't assume we have NIS (PC-NFS) or some other ID daemon
- // So we ...
- if ( (user = wxGetenv(wxT("USER"))) == NULL &&
- (user = wxGetenv(wxT("LOGNAME"))) == NULL )
- {
- // Use wxWidgets configuration data (comming soon)
- GetProfileString(WX_SECTION, eUSERID, default_id, buf, maxSize - 1);
- }
- else
- {
- wxStrncpy(buf, user, maxSize - 1);
- }
-
- return *buf ? true : false;
#endif
}
wxString name;
if(!key.QueryValue(wxT("Owner"),name))
return false;
- wxStrncpy(buf, name.c_str(), maxSize-1);
- buf[maxSize-1] = _T('\0');
+ wxStrlcpy(buf, name.c_str(), maxSize);
return true;
#elif defined(USE_NET_API)
CHAR szUserName[256];
if ( !ok )
{
- wxStrncpy(buf, wxT("Unknown User"), maxSize);
+ wxStrlcpy(buf, wxT("Unknown User"), maxSize);
}
return true;
TOKEN_PRIVILEGES tkp;
// Get the LUID for the shutdown privilege.
- ::LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
- &tkp.Privileges[0].Luid);
+ bOK = ::LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
+ &tkp.Privileges[0].Luid) != 0;
- tkp.PrivilegeCount = 1; // one privilege to set
- tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+ if ( bOK )
+ {
+ tkp.PrivilegeCount = 1; // one privilege to set
+ tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+ // Get the shutdown privilege for this process.
+ ::AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
+ (PTOKEN_PRIVILEGES)NULL, 0);
- // Get the shutdown privilege for this process.
- ::AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
- (PTOKEN_PRIVILEGES)NULL, 0);
+ // Cannot test the return value of AdjustTokenPrivileges.
+ bOK = ::GetLastError() == ERROR_SUCCESS;
+ }
- // Cannot test the return value of AdjustTokenPrivileges.
- bOK = ::GetLastError() == ERROR_SUCCESS;
+ ::CloseHandle(hToken);
}
}
wxZeroMemory(info);
info.dwOSVersionInfoSize = sizeof(info);
- if ( ::GetVersionEx(wx_reinterpret_cast(OSVERSIONINFO *, &info)) )
+ if ( ::GetVersionEx(reinterpret_cast<OSVERSIONINFO *>(&info)) )
{
switch ( info.wProductType )
{