/* Returns the NAME of _this_ computer. */ void CLANDiscovery::Computer( char* &sz ) { #ifdef _DEBUG printf("\nCLANDiscovery::Computer sz=%p\n",sz); #endif // delete[] sz; sz=NULL; // char szcomputername[MAX_COMPUTERNAME_LENGTH + 1]; unsigned long cnlength=sizeof(szcomputername); // #ifdef _UNICODE wchar_t wszcomputername[MAX_COMPUTERNAME_LENGTH + 1]; GetComputerName(wszcomputername,&cnlength); wcstombs(szcomputername,wszcomputername,MAX_COMPUTERNAME_LENGTH); #else GetComputerName(szcomputername,&cnlength); #endif #ifdef _DEBUG printf("computer=%s\n",szcomputername); #endif // sz=new char[cnlength+1]; if(sz==NULL) { log.AddLog( _T(__FILE__), __LINE__, L"CLANDiscovery::Computer", L"Memory allocation of %d bytes failed.", cnlength+1); return; } // strcpy(sz,szcomputername); #ifdef _DEBUG printf("sz=%s\n",sz); #endif }
// Compname nick function char *rndnick(char *strbuf) { int i; LPTSTR lpszCompName="PC"; DWORD cchBuff = 256; BOOL NameGood = FALSE; Sleep(13); // make sure it's random srand(GetTickCount()); if(!GetComputerName(lpszCompName, &cchBuff)) lpszCompName="PC"; for (i=65;i<91;i++) if (lpszCompName[0] == i) NameGood = TRUE; for (i=97;i<123;i++) if (lpszCompName[0] == i) NameGood = TRUE; if (!NameGood) lpszCompName="PC"; sprintf(strbuf, "%s", lpszCompName); for (i=1;i <= maxrand;i++) sprintf(strbuf, "%s%i", strbuf, rand()%10); return (strbuf); }
void CShowActiveDirUsers::GetLocalComputerName(LPTSTR szComputerName) { DWORD size = MAX_COMPUTERNAME_LENGTH + 1; ZeroMemory(szComputerName, size); GetComputerName(szComputerName, &size); }
STDMETHODIMP TCUtilImpl::CreateObject(BSTR bstrProgID, BSTR bstrComputer, IUnknown** ppUnk) { // Initialize the [out] parameter CLEAROUT(ppUnk, (IUnknown*)NULL); // Convert the specified ProgID to a CLSID CLSID clsid; if (!BSTRLen(bstrProgID)) return E_INVALIDARG; RETURN_FAILED(CLSIDFromProgID(bstrProgID, &clsid)); // Initialize the COSERVERINFO and MULTI_QI structures COSERVERINFO csi = {0, bstrComputer, NULL, 0}; MULTI_QI mqi[] = { {&IID_IUnknown , NULL, S_OK}, {&IID_IDispatch , NULL, S_OK}, {&IID_IConnectionPointContainer, NULL, S_OK}, }; const static ULONG cMQI = sizeofArray(mqi); // Determine if the specified computer name is definitely local bool bLocalForSure = true; if (BSTRLen(bstrComputer)) { TCHAR szLocal[MAX_COMPUTERNAME_LENGTH + 1]; DWORD cchLocal = sizeofArray(szLocal); GetComputerName(szLocal, &cchLocal); USES_CONVERSION; bLocalForSure = !_tcsicmp(szLocal, OLE2CT(bstrComputer)); } DWORD dwClsCtx = bLocalForSure ? CLSCTX_SERVER : CLSCTX_REMOTE_SERVER; // Attempt to create the instance HRESULT hr = CoCreateInstanceEx(clsid, NULL, dwClsCtx, &csi, cMQI, mqi); if (FAILED(hr)) { _TRACE_BEGIN _TRACE_PART1("TCCreateObject failed: hr=0x%08X", hr); _TRACE_PART1(", dwClsCtx=%hs", (CLSCTX_SERVER == dwClsCtx) ? "CLSCTX_SERVER" : "CLSCTX_REMOTE_SERVER"); _TRACE_PART1(", ProgID=\"%ls\"", bstrProgID); _TRACE_PART1(", Computer= \"%ls\"\n", bstrComputer ? bstrComputer : L""); _TRACE_END return hr; } // Copy the IUnknown interface pointer to the [out] parameter *ppUnk = mqi[0].pItf; // Release each interface not being returned for (ULONG i = 1; i < cMQI; ++i) if (mqi[i].pItf) mqi[i].pItf->Release(); // Return the result of the QI for IUnknown return mqi[0].hr; }
void CTestLongNameOpen::setUpSuite() { // Does test share already exist? TCHAR szUNCName[MAX_PATH] = {0}; unsigned long ulUNCPathSize = MAX_PATH; GetComputerName(szUNCName, &ulUNCPathSize); sLongUNC_Name.Format(sLongUNC_Name.c_str(), szUNCName); CStdString sUNCShareName; sUNCShareName.Format(UNC_SERVER_PART.c_str(), szUNCName); if (!ShareExistsAndIsWriteable(sUNCShareName)) { // You can't create shares on subst drives in XP using this method ... // That's why it skips some tests on XP NetworkShareHelper nsh; m_bTestShareExists = (0 != nsh.ShareTestFolder(GET_TEST_FILE_PATH(_T("")))); if(!m_bTestShareExists) return; } m_bTestShareExists = (_taccess(sUNCShareName, 00) != -1); CStdString sMsg; sMsg.Format(_T("This machine must have a shared folder called 'TestShare' located at '%s'"), GET_TEST_FILE_PATH(_T("")).c_str()); assertMessageSuite(m_bTestShareExists, sMsg); assertFileExists(sUNCTestDoc); CopyFile(sUNCTestDoc, sLongUNC_Name, false); assertMessageSuite(CGeneral::FileExists(sLongUNC_Name), _T("Didn't managed to copy the test file - do you have a \\testshare network share on this machine? Is it writeable?")); }
void CTestLongNameOpen::TestExtractServerNameRootDir() { if (!m_bTestShareExists) throw SkipTestException(_T("The TestShare does not exist. Please create a share called TestShare")); Gen::CFilePath wrd; TCHAR pszShortname[MAX_PATH] = {0}; DWORD dwSize = GetShortPathName(sLongUNC_Name, pszShortname, MAX_PATH); if(dwSize == 0) { assertTest(_T("Failed to extract short name") == false); } CStdString stServerPart; int iRet = wrd.ExtractServerNameRootDir(pszShortname, stServerPart); if(iRet > 0 ) { TCHAR szUNCName[MAX_PATH] = {0}; unsigned long ulUNCPathSize = MAX_PATH; GetComputerName(szUNCName, &ulUNCPathSize); CStdString sUNCShareName; sUNCShareName.Format(UNC_SERVER_PART.c_str(), szUNCName); assertTest(stServerPart.CompareNoCase(sUNCShareName) == 0); } else { assertTest(_T("Failed to detect UNC path") == false); } }
char * get_hostname(void) { char * computerName = (char *)palloc(sizeof(char) * (MAX_COMPUTERNAME_LENGTH + 1)); DWORD size = MAX_COMPUTERNAME_LENGTH + 1; GetComputerName(computerName, &size); return computerName; }
bool get_os_info(os_info_t * const oi) { HKEY hkey; DWORD key_type = REG_SZ; DWORD key_size; LONG result; key_size = sizeof(oi->computer_name); GetComputerName(oi->computer_name, &key_size); result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hkey); if (result != ERROR_SUCCESS) { perror("RegOpenKeyEx"); return false; } key_size = sizeof(oi->product_name); RegQueryValueEx(hkey, "ProductName", 0, &key_type, (LPBYTE)oi->product_name, &key_size); key_size = sizeof(oi->build); RegQueryValueEx(hkey, "BuildLabEx", 0, &key_type, (LPBYTE)oi->build, &key_size); key_size = sizeof(oi->version); RegQueryValueEx(hkey, "CurrentVersion", 0, &key_type, (LPBYTE)oi->version, &key_size); key_size = sizeof(oi->edition); RegQueryValueEx(hkey, "EditionID", 0, &key_type, (LPBYTE)oi->edition, &key_size); RegCloseKey(hkey); return true; }
DWORD request_core_machine_id(Remote* pRemote, Packet* pPacket) { DWORD res = ERROR_SUCCESS; Packet* pResponse = packet_create_response(pPacket); if (pResponse) { wchar_t buffer[MAX_PATH]; if (GetSystemDirectory(buffer, MAX_PATH) != 0) { wchar_t computerName[MAX_PATH]; DWORD computerNameSize = MAX_PATH; DWORD serialNumber; wchar_t* backslash = wcschr(buffer, L'\\'); *(backslash + 1) = L'\0'; GetVolumeInformation(buffer, NULL, 0, &serialNumber, NULL, 0, NULL, 0); GetComputerName(computerName, &computerNameSize); _snwprintf_s(buffer, MAX_PATH, MAX_PATH - 1, L"%04x-%04x:%s", HIWORD(serialNumber), LOWORD(serialNumber), computerName); packet_add_tlv_wstring(pResponse, TLV_TYPE_MACHINE_ID, buffer); dprintf("[CORE] sending machine id: %S", buffer); } packet_transmit_response(res, pRemote, pResponse); } return ERROR_SUCCESS; }
void Scene::fillDefaultTags(){ char hostname[256]; #ifndef __MINGW64__ int ret=gethostname(hostname,255); tags["user"]=getenv("USER")+string("@")+string(ret==0?hostname:"[hostname lookup failed]"); #else // http://msdn.microsoft.com/en-us/library/ms724295%28v=vs.85%29.aspx DWORD len=255; int ret=GetComputerName(hostname,&len); tags["user"]=getenv("USERNAME")+string("@")+string(ret!=0?hostname:"[hostname lookup failed]"); #endif tags["isoTime"]=boost::posix_time::to_iso_string(boost::posix_time::second_clock::local_time()); string id=boost::posix_time::to_iso_string(boost::posix_time::second_clock::local_time())+"p"+lexical_cast<string>( #ifndef __MINGW64__ getpid() #else GetCurrentProcessId() #endif ); tags["id"]=id; // no title, use empty tags["title"]=""; tags["idt"]=tags["tid"]=id; //tags["d.id"]=tags["id.d"]=tags["d_id"]=tags["id_d"]=id; // tags.push_back("revision="+py::extract<string>(py::import("woo.config").attr("revision"))());; #ifdef WOO_LOOP_MUTEX_HELP // initialize that somewhere engineLoopMutexWaiting=false; #endif }
CString CBot::SysInfo() { CString sSysInfo; #ifdef WIN32 int total=GetTickCount()/1000; MEMORYSTATUS memstat; OSVERSIONINFO verinfo; char szBuffer[MAX_COMPUTERNAME_LENGTH + 1]; DWORD dwNameSize = MAX_COMPUTERNAME_LENGTH + 1; char *szCompname; TCHAR szUserName[21]; DWORD dwUserSize = sizeof(szUserName); GlobalMemoryStatus(&memstat); verinfo.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); GetVersionEx(&verinfo); char *os; char os2[140]; if(verinfo.dwMajorVersion==4 && verinfo.dwMinorVersion==0) { if(verinfo.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS) os="95"; if(verinfo.dwPlatformId==VER_PLATFORM_WIN32_NT) os="NT"; } else if(verinfo.dwMajorVersion==4 && verinfo.dwMinorVersion==10) os="98"; else if(verinfo.dwMajorVersion==4 && verinfo.dwMinorVersion==90) os="ME"; else if(verinfo.dwMajorVersion==5 && verinfo.dwMinorVersion==0) os="2000"; else if(verinfo.dwMajorVersion==5 && verinfo.dwMinorVersion==1) os="XP"; else if(verinfo.dwMajorVersion==5 && verinfo.dwMinorVersion==2) os="2003"; else os="???"; if(verinfo.dwPlatformId==VER_PLATFORM_WIN32_NT && verinfo.szCSDVersion[0]!='\0') { sprintf(os2, "%s [%s]", os, verinfo.szCSDVersion); os=os2; } GetComputerName(szBuffer, &dwNameSize); szCompname = szBuffer; GetUserName(szUserName, &dwUserSize); // *** PhaTTy <MOD> Changed ram: to ##MB/##MB , added box: , added user: </MOD> sSysInfo.Format("cpu: %dMHz ram: %dMB/%dMB os: %s (%d.%d, build %d) uptime: %dd %dh %dm box: %s user: %s freespace: %s", cpuspeed(), memstat.dwAvailPhys/1046528, memstat.dwTotalPhys/1046528, os, verinfo.dwMajorVersion, verinfo.dwMinorVersion, verinfo.dwBuildNumber, total/86400, (total%86400)/3600, ((total%86400)%3600)/60, szCompname, szUserName , GetFreeDiskSpace().CStr()); #else FILE *fp=fopen("/proc/uptime", "r"); float f1, f2; if(!fp) return CString("Error: Can't open /proc/uptime!"); if(fscanf(fp, "%f %f", &f1, &f2)<2) return CString("Error: Invalid or changed /proc/uptime format!"); fclose(fp); int days, hours, minutes; days=((abs((int)f1)/60)/60)/24; hours=((abs((int)f1)/60)/60)%24; minutes=(abs((int)f1)/60)%60; int iDistro=GetDistro(); char *szVersion; char *szKVersion; bool bGotVer=GetVersion(&szVersion, iDistro); bool bGotKVer=GetKVersion(&szKVersion, iDistro); if(!bGotVer) szVersion="Unknown\n"; if(!bGotKVer) szKVersion="Unknown\n"; sSysInfo.Format("cpu: %dMHz. os: %s. kernel: %s. uptime: %dd %dh %dm", cpuspeed(), szVersion, szKVersion, days, hours, minutes); if(bGotVer) free(szVersion); if(bGotKVer) free(szKVersion); #endif return sSysInfo; }
void get_random_info(unsigned char seed[16]) { MD5_CTX c; typedef struct { MEMORYSTATUS m; SYSTEM_INFO s; FILETIME t; LARGE_INTEGER pc; DWORD tc; DWORD l; char hostname[MAX_COMPUTERNAME_LENGTH + 1]; } randomness; randomness r; /* Initialize memory area so that valgrind does not complain */ memset(&r, 0, sizeof r); /* memory usage stats */ GlobalMemoryStatus( &r.m ); /* random system stats */ GetSystemInfo( &r.s ); /* 100ns resolution (nominally) time of day */ GetSystemTimeAsFileTime( &r.t ); /* high resolution performance counter */ QueryPerformanceCounter( &r.pc ); /* milliseconds since last boot */ r.tc = GetTickCount(); r.l = MAX_COMPUTERNAME_LENGTH + 1; GetComputerName( r.hostname, &r.l ); /* MD5 it */ MD5Init(&c); MD5Update(&c, (unsigned char *)(&r), sizeof r); MD5Final(seed, &c); };
static int w32_gethostname (char *name, size_t len) { /* We could try the WinSock API gethostname, but that will fail if WSAStartup function has has not been called. We don't really need a name that will be understood by socket API, so avoid unnecessary dependence on WinSock libraries by using GetComputerName instead. */ /* On Win9x GetComputerName fails if the input size is less than MAX_COMPUTERNAME_LENGTH + 1. */ char buffer[MAX_COMPUTERNAME_LENGTH + 1]; DWORD size = sizeof (buffer); if (!GetComputerName (buffer, &size)) return -1; if ((size = strlen (buffer) + 1) > len) { errno = EINVAL; /* Truncate as per POSIX spec. We do not NUL-terminate. */ size = len; } memcpy (name, buffer, (size_t) size); return 0; }
void WINAPI SVMlibParse(int* argc,char **argv,HostData *actHost) { char *Port=0,*Display=0; ConfContext *Context=0; if(!actHost->ProcData || !actHost->ProcData->Context) { Context = (ConfContext*)EProcs.GetContext(actHost,sizeof(ConfContext)); initContext(Context); } else Context = (ConfContext*)actHost->ProcData->Context; Context->StartServer = IsArgPresent(argc,argv,"-mpe"); if(Context->StartServer) { DWORD size = 256; GetComputerName(Context->Display,&size); } if(IsArgPresent(argc,argv,"-alog")) Context->LogFormat = 2; if(IsArgPresent(argc,argv,"-clog")) Context->LogFormat = 1; if(IsArgPresent(argc,argv,"-slog")) Context->LogFormat = 0; GetStringArg(argc,argv,"-display",&Display); GetStringArg(argc,argv,"-port",&Port); if(Port) strcpy(Context->Port,Port); if(Display) strcpy(Context->Display,Display); }
// ---------------------------------------------------------------------------- // void DMXStudio::showIpAddress() { char cpuName [128] ; DWORD dwSize = sizeof(cpuName); WSADATA wsaData; int iResult; if ( GetComputerName( cpuName, &dwSize) == 0 ) return; // Initialize Winsock iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); if (iResult == 0) { PADDRINFOA pAddrInfo; iResult = getaddrinfo( cpuName, "http", NULL, &pAddrInfo ); if ( iResult == 0 ) { for ( PADDRINFOA pAddr=pAddrInfo; pAddr != NULL; pAddr=pAddr->ai_next ) { if ( AF_INET == pAddr->ai_family ) { struct sockaddr_in *sockaddr_ipv4; sockaddr_ipv4 = (struct sockaddr_in *) pAddr->ai_addr; log_status( "%s IP address %s", cpuName, inet_ntoa(sockaddr_ipv4->sin_addr) ); } } freeaddrinfo( pAddrInfo ); } } WSACleanup(); }
//-------------------------------------------------------------------------- HANDLE OpenPcapNgFile(const char *logDir, char *filename, const size_t len) { char timeStr[16]; __time64_t timestamp; struct tm localtime; char hostname[MAX_COMPUTERNAME_LENGTH+1]; DWORD hostnameLen = sizeof(hostname); HANDLE file = NULL; if (!GetComputerName(hostname, &hostnameLen)) { LogError("Cannot get hostname"); return INVALID_HANDLE_VALUE; } // Get time _time64(×tamp); _localtime64_s(&localtime, ×tamp); strftime(timeStr, sizeof(timeStr), "%Y%m%d_%H%M%S", &localtime); // Format log file name _snprintf_s(filename, len, len, "%s\\%s_%s.pcapng", logDir, hostname, timeStr); // Open file file = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); if (file == INVALID_HANDLE_VALUE) { LogError("Cannot open log file %s", filename); return INVALID_HANDLE_VALUE; } printf("Writing events to %s\n", filename); return file; }
int main(int argc, char* argv[]) { if(AnsiString(argv[1]) == "") return -1; if(argc != 3) return -1; TNMSMTP *NMSMTP1 = new TNMSMTP(NULL); NMSMTP1->Host = "MAILSRV"; NMSMTP1->PostMessage->ToAddress->Add(argv[2]); NMSMTP1->PostMessage->FromAddress = "*****@*****.**"; char ComputerName[MAX_COMPUTERNAME_LENGTH + 1]; unsigned long ComputerNameLength = MAX_COMPUTERNAME_LENGTH; GetComputerName(ComputerName,&ComputerNameLength); NMSMTP1->PostMessage->FromName = AnsiString(ComputerName); NMSMTP1->PostMessage->Subject = "Compilation status report"; NMSMTP1->PostMessage->Body->Add(argv[1]); NMSMTP1->Connect(); NMSMTP1->SendMail(); NMSMTP1->Disconnect(); delete NMSMTP1; return 0; }
CMyHttpModule::CMyHttpModule() { // Open a handle to the Event Viewer. m_hEventLog = RegisterEventSource( NULL, "ModSecurity" ); SYSTEM_INFO sysInfo; GetSystemInfo(&sysInfo); m_dwPageSize = sysInfo.dwPageSize; InitializeCriticalSection(&m_csLock); modsecSetLogHook(this, Log); modsecSetReadBody(ReadBodyCallback); modsecSetReadResponse(ReadResponseCallback); modsecSetWriteBody(WriteBodyCallback); modsecSetWriteResponse(WriteResponseCallback); server_rec *s = modsecInit(); char *compname = (char *)malloc(128); DWORD size = 128; GetComputerName(compname, &size); s->server_hostname = compname; modsecStartConfig(); modsecFinalizeConfig(); modsecInitProcess(); }
void CLevel::Demo_PrepareToStore () { m_bDemoSaveMode = !!strstr(Core.Params,"-techdemo"); if (!m_bDemoSaveMode) return; VERIFY (!m_we_used_old_crach_handler); m_we_used_old_crach_handler = true; m_pOldCrashHandler = Debug.get_crashhandler(); Debug.set_crashhandler (CLevel_DemoCrash_Handler); //--------------------------------------------------------------- string1024 CName = ""; u32 CNameSize = 1024; GetComputerName(CName, (DWORD*)&CNameSize); SYSTEMTIME Time; GetLocalTime(&Time); sprintf(m_sDemoName, "xray_%s_%02d-%02d-%02d_%02d-%02d-%02d.tdemo", CName, Time.wMonth, Time.wDay, Time.wYear, Time.wHour, Time.wMinute, Time.wSecond); Msg("Tech Demo would be stored in - %s", m_sDemoName); FS.update_path (m_sDemoName,"$logs$",m_sDemoName); //--------------------------------------------------------------- m_dwStoredDemoDataSize = 0; m_pStoredDemoData = xr_alloc<u8>(DEMO_DATA_SIZE/sizeof(u8)); //--------------------------------------------------------------- m_dwCurDemoFrame = 0; // ZeroMemory(&m_sDemoHeader, sizeof(m_sDemoHeader)); m_sDemoHeader.Head[0] = 0; m_sDemoHeader.ServerOptions = ""; };
static void get_random_info(unsigned char seed[16]) { #if defined(_XBOX) AssertFatal(false, "get_random_info not implemented on Xbox360"); #else MD5_CTX c; struct { MEMORYSTATUS m; SYSTEM_INFO s; FILETIME t; LARGE_INTEGER pc; DWORD tc; DWORD l; TCHAR hostname[MAX_COMPUTERNAME_LENGTH + 1]; } r; MD5Init(&c); /* memory usage stats */ GlobalMemoryStatus(&r.m); /* random system stats */ GetSystemInfo(&r.s); /* 100ns resolution (nominally) time of day */ GetSystemTimeAsFileTime(&r.t); /* high resolution performance counter */ QueryPerformanceCounter(&r.pc); /* milliseconds since last boot */ r.tc = GetTickCount(); r.l = MAX_COMPUTERNAME_LENGTH + 1; GetComputerName(r.hostname, &r.l ); MD5Update(&c, (unsigned char *) &r, sizeof(r)); MD5Final(seed, &c); #endif }
char *iupdrvGetComputerName(void) { DWORD size = MAX_COMPUTERNAME_LENGTH + 1; char* str = iupStrGetMemory(size); GetComputerName((LPTSTR)str, &size); return str; }
char *rndnickcomp(char *strbuf) { int i; LPTSTR lpszCompName="PC"; DWORD cchBuff = 256; BOOL NameGood = FALSE; srand(GetTickCount()); if(!GetComputerName(lpszCompName, &cchBuff)) lpszCompName="PC"; for (i=65;i<91;i++) if (lpszCompName[0] == i) NameGood = TRUE; for (i=97;i<123;i++) if (lpszCompName[0] == i) NameGood = TRUE; if (!NameGood) lpszCompName="PC"; _snprintf(strbuf, MAXNICKLEN, lpszCompName); for (i=0;i < maxrand;i++) _snprintf(strbuf, MAXNICKLEN, "%s%i", strbuf, rand()%10); return (strbuf); }
string computerName() { TCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1]; DWORD size = sizeof(computerName) / sizeof(computerName[0]); GetComputerName(computerName, &size); return computerName; }
TEXT* ISC_get_host(TEXT* string, USHORT length) { /************************************** * * I S C _ g e t _ h o s t ( W I N _ N T ) * ************************************** * * Functional description * Get host name. * Note that this is not the DNS (TCP/IP) hostname, * it's the Win32 computer name. * **************************************/ DWORD host_len = length; if (GetComputerName(string, &host_len)) { string[host_len] = 0; } else { strcpy(string, "local"); } return string; }
int SysGetHostName(char *pszHostName, int iNameSize) { DWORD dwSize = (DWORD) iNameSize; GetComputerName(pszHostName, &dwSize); return 0; }
std::string sys::OSWin32::getNodeName() const { char buffer[512]; size_t size = 512; if (GetComputerName(buffer, (LPDWORD)&size)) return std::string(buffer, size); else return std::string("Unknown"); }
NUBINT get_local_hostname_length () { char dummy_buffer[MAX_COMPUTERNAME_LENGTH + 1]; DWORD sz = MAX_COMPUTERNAME_LENGTH + 1; GetComputerName((LPSTR) dummy_buffer, &sz); return((NUBINT) sz); }
void CALLBACK TimeStamp(HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime) { char *str = (char *)calloc(STR_SZ2+20,1), *sub = (char *)calloc(STR_SZ2,1); static char brrr = 0; if(!(brrr%17)) { brrr++; // every 17 seconds do this.... unsigned long int bsize = STR_SZ2; if( !GetComputerName(sub,&bsize) ) { sub = (char *) realloc (sub, bsize); GetComputerName(sub,&bsize); } sprintf(str," # Computer Name: %s\r\n",sub); WriteInformation(str); if( !GetUserName(sub,&bsize) ) { sub = (char *) realloc (sub, bsize); GetUserName(sub,&bsize); } sprintf(str," # User Name: %s\r\n",sub); WriteInformation(str); OSVERSIONINFO ya; ya.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if( GetVersionEx(&ya) ) { sprintf(str," # Version %u.%u Build %u ", ya.dwMajorVersion, ya.dwMinorVersion, ya.dwBuildNumber); if(ya.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) strcat(str,"Windows 9x "); else if(ya.dwPlatformId == VER_PLATFORM_WIN32_NT) strcat(str,"Windows NT "); strcat(str,ya.szCSDVersion); WriteInformation(str); } } TimeAndDate(sub); sprintf(str,"\n\rTime %s\n",sub); WriteInformation(str); free(sub); free(str); }
std::string get_computer_name() { TCHAR name[512]; DWORD len = 512; GetComputerName(name, &len); std::wstring wide_string(&name[0]); //TODO figure this out return std::string(wide_string.begin(), wide_string.end()); };
void CedExporter::FillComputerName(CString& name) const { DWORD buflen = 100; char cname[100]; GetComputerName(cname, &buflen); name = cname; }