Exemple #1
0
// get pointer to end of list
TCHAR _far * PASCAL end_of_env( TCHAR _far *pchList )
{
	for ( ; ( *pchList != _TEXT('\0') ); pchList = next_env( pchList ))
		;

	return pchList;
}
clock_t CServerQuery::QueryWithPlayers( const char* szIP, unsigned short usPort )
{

	struct hostent     *he;
	if ( ( he = gethostbyname( szIP ) ) == NULL ) 
	{
		//MessageBox( 0, _TEXT("Unable to resolve IP of server"), _TEXT("Error"), MB_ICONEXCLAMATION | MB_OK );
		return 0;
	}

	SOCKADDR_IN	pTarget;
	pTarget.sin_family = AF_INET; // address family Internet
	pTarget.sin_port = htons( usPort ); //Port to connect on
	pTarget.sin_addr.s_addr = *( (unsigned long*)he->h_addr ); //Target IP

	static unsigned char szBuf[ 12 ]= { 0 };
	vcmpq_request pRequest;

	pRequest.ulIP = pTarget.sin_addr.s_addr;
	pRequest.usPort = usPort;
	pRequest.eRequestType = VCMPQ_HEADERTYPE_QUERY;
	VCMPQ_CreateQuery( pRequest, szBuf );

	if ( m_pSocket )
	{
		int iLen = sendto( m_pSocket, (char*)szBuf, 11, 0, (const sockaddr*)&pTarget, sizeof( struct sockaddr ) );

		if ( iLen == 0 )
		{
			MessageBox( 0, _TEXT("Failed to query"), _TEXT("Error"), MB_ICONEXCLAMATION | MB_OK );
		}
		else
		{
			pRequest.eRequestType = VCMPQ_HEADERTYPE_PLAYERS;
			VCMPQ_CreateQuery( pRequest, szBuf );

			iLen = sendto( m_pSocket, (char*)szBuf, 11, 0, (const sockaddr*)&pTarget, sizeof( struct sockaddr ) );

			if ( iLen == 0 )
			{
				MessageBox( 0, _TEXT("Failed to query"), _TEXT("Error"), MB_ICONEXCLAMATION | MB_OK );
			}
		}
	}

	return clock();
}
Exemple #3
0
// write the file (or pipe) to another file
static void _near ListSaveFile( void )
{
	int i, nFH, nMode;
	long lTemp;
	POPWINDOWPTR wn;
	TCHAR szBuffer[ MAXLISTLINE+1 ];
	
	// disable ^C / ^BREAK handling
	HoldSignals();
	
	wn = wOpen( 2, 1, 4, GetScrCols() - 2, nInverse, LIST_SAVE_TITLE, NULL );
	wn->nAttrib = nNormal;
	wClear();
	wWriteListStr( 0, 1, wn, LIST_QUERY_SAVE );
	egets( szBuffer, MAXFILENAME, EDIT_DATA | EDIT_BIOS_KEY );
	
	if ( szBuffer[0] ) {
		
		// save start position
		lTemp = LFile.lViewPtr;
		
		nMode = _O_BINARY;
		
		if (( nFH = _sopen( szBuffer, ( nMode | _O_WRONLY | _O_CREAT | _O_TRUNC ), _SH_DENYNO, _S_IWRITE | _S_IREAD )) >= 0 ) {
			
			// reset to beginning of file

				ListSetCurrent( 0L );
			
			do {
				
				for ( i = 0; ( i < MAXLISTLINE ); i++ ) {
					
					// don't call GetNextChar unless absolutely necessary
					if ( LFile.lpCurrent == LFile.lpEOF )
						break;

					szBuffer[i] = (TCHAR)GetNextChar();
				}

				szBuffer[i] = _TEXT('\0');
				
			} while (( i > 0 ) && ( wwrite( nFH, szBuffer, i ) > 0 ));
			
			_close( nFH );
			
			// restore start position
			LFile.lViewPtr = lTemp;
			ListSetCurrent( LFile.lViewPtr );
			
		} else
			honk();
	}
	
	wRemove( wn );
	
	// enable ^C / ^BREAK handling
	EnableSignals();
}
Exemple #4
0
	void Matcher::appendIndices(const std::shared_ptr<StringBuilder> &sb, const std::string &prefix, std::vector<int> &indexArray, std::vector<std::string> &componentNames) {
		constexpr std::string SEPARATOR = _TEXT(", ");
		sb->Append(prefix);
		sb->Append(_TEXT("("));
		auto lastSeparator = indexArray.size() - 1;
		for(int i = 0, indicesLength = indexArray.size(); i < indicesLength; i++) {
			auto index = indexArray[i];
			if(componentNames.empty())
				sb->Append(index);
			else
				sb->Append(componentNames[index]);

			if(i < lastSeparator)
				sb->Append(SEPARATOR);
		}
		sb->Append(_TEXT(")"));
	}
Exemple #5
0
  string
  Timer::timeAndPercentString(double dRelativeToSeconds) const {
    string strAccumulatedTime("0");
    double dRelativeTime = 0.0;
    if (getAccumulatedTime() > FLT_MIN) {
      double2String(getAccumulatedTime(), cuiSecDigits_After_Period, strAccumulatedTime);
      dRelativeTime = (getAccumulatedTime() / dRelativeToSeconds);
    }
    string strRelativePct;
    double2String(100.0 * dRelativeTime, cuiPctDigits_After_Period , strRelativePct);

    return (getDescription() +
            strpad_l_copy(strAccumulatedTime, (size_t)6) +
            _TEXT(" seconds (") +
            strpad_l_copy(strRelativePct, (size_t)cuiPctDigits_After_Period+3) +
            _TEXT("%)"));
  }
Exemple #6
0
// Remove the newlines, if any. Works on both DOS and *nix newlines
void chop_line(char *s)
{
  size_t pos = strlen(s);

  while (pos > 0) 
  {
    // We split up the two checks because we can never know which
    // condition the computer will examine if first. If pos == 0, we
    // don't want to be checking s[pos-1] under any circumstances! 

    if (!(s[pos-1] == _TEXT('\r') || s[pos-1] == _TEXT('\n')))
      return;

    s[pos-1] = 0;
    --pos;
  }
}
Exemple #7
0
 string
 Timer::timeAndPercentAndThroughputString(
   double            dRelativeToSeconds,
   size_t            uiRelativeToItems,
   const string &   strItemsname
 ) const {
   string s;
   string s2;
   return getDescription() +
          strpad_l_copy(double2String(getAccumulatedTime(), cuiSecDigits_After_Period, s), (size_t)6) +
          _TEXT(" seconds (") +
          strpad_l_copy(double2String(100.0 * (getAccumulatedTime() / dRelativeToSeconds), cuiPctDigits_After_Period , s), (size_t)cuiPctDigits_After_Period+3) +
          _TEXT("% ") +
          double2String(uiRelativeToItems / getAccumulatedTime(), cuiPctDigits_After_Period, s2)  +
          _TEXT(" ") + (strItemsname.length() == 0 ? (string)_TEXT("items") : strItemsname) +
          _TEXT("/sec)");
 }
BOOL CYangLiuImageProcess::ReadImage(LPCTSTR lpszPathName)
{
	IplImage *image = (IplImage*)voidImage;
	CString str = lpszPathName;
	str.MakeLower();
	if (str.Find(_TEXT(".bmp")) != -1)
	{
		m_nOpenMode = 1;
		if (!ReadBMP(lpszPathName)) return FALSE;
		
		CvSize size;
		size.height = imageHeight;
		size.width = imageWidth;
		image = cvCreateImageHeader(size, 8, m_nColorBits / 8);
		image->imageData = (char *)m_pBits;
	}
	if (str.Find(_TEXT(".jpg")) != -1)
	{
		m_nOpenMode = 2;
		image = cvLoadImage(lpszPathName);
		lpbmi = (LPBITMAPINFO) new char[sizeof(BITMAPINFO)+4 * (1 << 8)];
		lpbmi->bmiHeader.biBitCount = image->depth*image->nChannels;
		lpbmi->bmiHeader.biClrUsed = 0;
		lpbmi->bmiHeader.biHeight = image->height;
		lpbmi->bmiHeader.biWidth = image->width;
		lpbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
		lpbmi->bmiHeader.biSizeImage = image->width*image->height*image->nChannels;
		lpbmi->bmiHeader.biClrImportant = 0;
		lpbmi->bmiHeader.biCompression = 0;
		lpbmi->bmiHeader.biPlanes = 1; //image->nChannels;
		imageWidth = image->width;
		imageHeight = image->height;
		for (int i = 0; i<(1 << 8); i++)
		{
			RGBQUAD &o = lpbmi->bmiColors[i];
			o.rgbBlue = i;
			o.rgbGreen = i;
			o.rgbRed = i;
			o.rgbReserved = 0;
		}
		m_nColorBits = image->depth*image->nChannels;
		m_pBits = (unsigned char *)image->imageData;
	}
	voidImage = (void *)image;
	return TRUE;
}
    //-------------------------------------------------------------------------
    static LPCTSTR GenerateTempBatchFileName()
    {
        // Make temp file name
        static TCHAR CmdFileName[MAX_PATH * 2];
        if (GetTempPath(_countof(CmdFileName), CmdFileName) == 0)
        {
            if (GetEnvironmentVariable(_TEXT("TEMP"), CmdFileName, _countof(CmdFileName)) == 0)
                return false;
        }

        if (CmdFileName[_tcslen(CmdFileName) - 1] != TCHAR('\\'))
            _tcsncat_s(CmdFileName, _TEXT("\\"), _countof(CmdFileName));

        _tcsncat_s(CmdFileName, STR_RESET_FN, _countof(CmdFileName));

        return CmdFileName;
    }
Exemple #10
0
int _RTLENTRY _EXPFUNC _vsntprintf(_TCHAR *bufP, size_t nsize,
                                   const _TCHAR *fmt, va_list ap)
{
    if (nsize >= 1)
        *bufP = _TEXT('\0');

    return  __vprintert ((putnF *)strputn, &bufP, fmt, 1, nsize, ap);
}
HRESULT CAzRole::Copy(CAzRole &srcRole) {

    CAzLogging::Entering(_TEXT("CAzRole::Copy"));

    CComBSTR bstrData;

    HRESULT hr=m_native->Submit(0,CComVariant());

    CAzLogging::Log(hr,_TEXT("Submitting for role"),COLE2T(getName()));

    if (FAILED(hr))
        goto lError1;

    hr=srcRole.m_native->get_Description(&bstrData);

    CAzLogging::Log(hr,_TEXT("Getting Description for role"),COLE2T(getName()));

    if (SUCCEEDED(hr)) {

        hr=m_native->put_Description(bstrData);

        CAzLogging::Log(hr,_TEXT("Setting Description for role"),COLE2T(getName()));

        bstrData.Empty();
    }

    hr=srcRole.m_native->get_ApplicationData(&bstrData);

    CAzLogging::Log(hr,_TEXT("Getting ApplicationData for role"),COLE2T(getName()));

    if (SUCCEEDED(hr)) {

        hr=m_native->put_ApplicationData(bstrData);

        CAzLogging::Log(hr,_TEXT("Setting ApplicationData for role"),COLE2T(getName()));

    }

    hr=CopyUserData(srcRole);

    CAzLogging::Log(hr,_TEXT("CopyUserData for role"),COLE2T(getName()));

    hr=m_native->Submit(0,CComVariant());

    CAzLogging::Log(hr,_TEXT("Submitting for role"),COLE2T(getName()));

lError1:
    CAzLogging::Exiting(_TEXT("CAzRole::Copy"));

    return hr;
}
LRESULT CALLBACK TinyConsoleWinProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    switch (message)
    {
	case WM_CREATE:
		{
			::GetSystemDirectory(strPath , MAX_PATH + 1);
			wsprintf(strPath, TEXT("%s\\%s"), strPath, _TEXT("RICHED20.DLL"));
			s_hRtLib = ::LoadLibrary((LPCTSTR)strPath);
			s_hRichEdit = ::CreateWindowEx(WS_EX_CLIENTEDGE,
					_T("RichEdit20A"),
					_T(""),
					WS_CHILD | WS_VISIBLE | WS_BORDER | ES_MULTILINE | WS_HSCROLL |
					WS_VSCROLL | ES_AUTOVSCROLL | ES_NOHIDESEL | ES_READONLY,
					0,80,200,200,
					hWnd,
					(HMENU)IDC_RICHEDIT,
					g_hTCInstance,
					NULL);

			DWORD dwLangOptions;
			CHARFORMAT  cfm;    // CHARFORMAT structure

			dwLangOptions = ::SendMessage(s_hRichEdit, EM_GETLANGOPTIONS, 0, 0);
            dwLangOptions &= ~IMF_DUALFONT;
            ::SendMessage(s_hRichEdit, EM_SETLANGOPTIONS, 0, (LPARAM)dwLangOptions);

			memset(&cfm, 0, sizeof(CHARFORMAT));
            cfm.cbSize = sizeof(CHARFORMAT);
			cfm.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT |
				CFM_CHARSET | CFM_FACE | CFM_COLOR | CFM_SIZE;

			cfm.yHeight = 14 * 20;
            cfm.bCharSet = SHIFTJIS_CHARSET;  //�iShiftJIS�j
			lstrcpy(cfm.szFaceName, _T("FixedSys"));//FixedSys System Terminal

			cfm.crTextColor = RGB(0, 0, 0);
			cfm.dwEffects = 0;

            ::SendMessage(s_hRichEdit,
                    EM_SETCHARFORMAT,
                    SCF_SELECTION | SCF_WORD,
                    (LPARAM)&cfm);
			::SendMessage( s_hRichEdit, EM_REPLACESEL, FALSE, (LPARAM)(LPCTSTR)_T("hook enable.\n") );
			if( g_hTinyConsole ){
				::SetEvent( g_hTinyConsole );
			}
		}
		break;
	case WM_SIZE:
		::MoveWindow(s_hRichEdit, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
		break;
	default:
		return ::DefWindowProc( hWnd, message, wParam, lParam );
		break;
	}
	return 0;
}
Exemple #13
0
/*
* CreateMetSectFileView
*/
BOOL CreateMetSectFileView(LPMETERED_SECTION lpMetSect, 
						   LONG lInitialCount, LONG lMaximumCount,
						   LPCTSTR lpName, BOOL bOpenOnly)
{
	TCHAR sz[MAX_PATH];
	DWORD dwLastError; 

	if (lpName)
	{
		wsprintf(sz, _TEXT("DKC_MSECT_MMF_%s"), lpName);

#ifndef _WIN32_WCE
		if (bOpenOnly)
		{
			lpMetSect->hFileMap = OpenFileMapping(0, FALSE, sz);
		}
		else
		{
#endif
			// Create a named file mapping
			lpMetSect->hFileMap = CreateFileMapping(INVALID_HANDLE_VALUE, 
				NULL, PAGE_READWRITE, 0, sizeof(METSECT_SHARED_INFO), sz);
#ifndef _WIN32_WCE
		}
#endif
	}
	else
	{
		// Create an unnamed file mapping
		lpMetSect->hFileMap = CreateFileMapping(INVALID_HANDLE_VALUE, 
			NULL, PAGE_READWRITE, 0, sizeof(METSECT_SHARED_INFO), NULL);
	}

	// Map a view of the file
	if (lpMetSect->hFileMap)
	{
		dwLastError = GetLastError();
		lpMetSect->lpSharedInfo = (LPMETSECT_SHARED_INFO) 
			MapViewOfFile(lpMetSect->hFileMap, FILE_MAP_WRITE, 0, 0, 0);
		if (lpMetSect->lpSharedInfo)
		{
			if (dwLastError != ERROR_ALREADY_EXISTS)
			{
				lpMetSect->lpSharedInfo->lSpinLock = 0;
				lpMetSect->lpSharedInfo->lThreadsWaiting = 0;
				lpMetSect->lpSharedInfo->lAvailableCount = lInitialCount;
				lpMetSect->lpSharedInfo->lMaximumCount = lMaximumCount;
				InterlockedExchange(&(lpMetSect->lpSharedInfo->fInitialized), TRUE);
			}
			else
			{   // Already exists; wait for it to be initialized by the creator
				while (!lpMetSect->lpSharedInfo->fInitialized) Sleep(0);
			}
			return TRUE;
		}
	}
	return FALSE;
}
Exemple #14
0
static BOOL
AddSelectedGroupsToUser(HWND hwndDlg,
                        PMEMBERSHIP_USER_DATA pUserData)
{
    HWND hwndLV;
    INT nItem;
    TCHAR szGroupName[UNLEN];
    BOOL bResult = FALSE;
    BOOL bFound;
    DWORD i;
    LOCALGROUP_MEMBERS_INFO_3 memberInfo;
    NET_API_STATUS status;

    hwndLV = GetDlgItem(hwndDlg, IDC_USER_ADD_MEMBERSHIP_LIST);

    if (ListView_GetSelectedCount(hwndLV) > 0)
    {
        nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
        while (nItem != -1)
        {
            /* Get the new user name */
            ListView_GetItemText(hwndLV,
                                 nItem, 0,
                                 szGroupName,
                                 UNLEN);

            bFound = FALSE;
            for (i = 0; i < pUserData->dwGroupCount; i++)
            {
                if (_tcscmp(pUserData->pGroupData[i].lgrui0_name, szGroupName) == 0)
                    bFound = TRUE;
            }

            if (!bFound)
            {
                memberInfo.lgrmi3_domainandname = pUserData->szUserName;

                status = NetLocalGroupAddMembers(NULL, szGroupName, 3,
                                                 (LPBYTE)&memberInfo, 1);
                if (status == NERR_Success)
                {
                    DebugPrintf(_TEXT("Selected group: %s"), szGroupName);
                    bResult = TRUE;
                }
                else
                {
                    TCHAR szText[256];
                    wsprintf(szText, TEXT("Error: %u"), status);
                    MessageBox(NULL, szText, TEXT("NetLocalGroupAddMembers"), MB_ICONERROR | MB_OK);
                }
            }

            nItem = ListView_GetNextItem(hwndLV, nItem, LVNI_SELECTED);
        }
    }

    return bResult;
}
Exemple #15
0
		CheckMemory() : hKernel32(NULL), FEGlobalMemoryStatusEx(NULL), FEGlobalMemoryStatus(NULL)
		{
			hKernel32 = ::LoadLibrary(_TEXT("Kernel32"));
			if (hKernel32)  
			{
				FEGlobalMemoryStatusEx = (PFGlobalMemoryStatusEx)::GetProcAddress(hKernel32, "GlobalMemoryStatusEx");
				FEGlobalMemoryStatus = (PFGlobalMemoryStatus)::GetProcAddress(hKernel32, "GlobalMemoryStatus");
			}
		}
Exemple #16
0
void MakeStringToNum(CString str,LONGLONG &Num)
{
	CString strNumber = str;
	strNumber.Remove(',');
	strNumber.Trim();
	_snscanf(strNumber.GetBuffer(),strNumber.GetLength(),_TEXT("%I64d"),&Num);

	return;
}
Exemple #17
0
	std::string Matcher::ToString() {
		if(_toStringCache == _TEXT("")) {
			auto sb = std::make_shared<StringBuilder>();
			if(_allOfIndices.size() > 0)
				appendIndices(sb, _TEXT("AllOf"), _allOfIndices, componentNames);
			if(_anyOfIndices.size() > 0) {
				if(_allOfIndices.size() > 0)
					sb->Append(_TEXT("."));
				appendIndices(sb, _TEXT("AnyOf"), _anyOfIndices, componentNames);
			}
			if(_noneOfIndices.size() > 0)
				appendIndices(sb, _TEXT(".NoneOf"), _noneOfIndices, componentNames);
//C# TO C++ CONVERTER TODO TASK: There is no native C++ equivalent to 'ToString':
			_toStringCache = sb->ToString();
		}

		return _toStringCache;
	}
//-------------------------------------------------------------------------
void ResetPermissionDialog::BackRestorePermissions(bool bBackup)
{
    // Browse for permission backup file
    stringT PermsFile;
    if (!ResetPermissionDialog::BrowseFileName(
        bBackup,
        bBackup ? STR_TITLE_BACKUP_PERMS : STR_TITLE_RESTORE_PERMS,
        TEXT("permissions.txt"),
        TEXT("*.txt"),
        PermsFile))
    {
        return;
    }

    QuotePath(PermsFile);

    // Get the folder location
    stringT folder;
    if (GetFolderText(folder, false, bBackup ? true : false, true) == 0)
        return;

    stringT cmd;
    InitCommand(cmd);

    // Update the command prompt's title
    if (bBackup)
    {
        cmd += _TEXT("TITLE Backing up permissions of folder: ") + folder + STR_NEWLINE;

        cmd += STR_CMD_ICACLS + folder + _TEXT(" /save ") + PermsFile;
        if (bRecurse)
            cmd += _TEXT(" /T ");
    }
    else
    {
        cmd += _TEXT("TITLE Restoring permissions of folder: ") + folder + STR_NEWLINE;

        cmd += STR_CMD_ICACLS + folder + _TEXT(" /restore ") + PermsFile;
    }

    cmd += STR_NEWLINE2 + STR_CMD_PAUSE;

    SetCommandWindowText(cmd.c_str());
}
BOOL InjectDLL(TCHAR* szDllName)
{ 
	TCHAR szDirectoryPath[MAX_PATH];

	GetCurrentDirectory(MAX_PATH, szDirectoryPath);
	lstrcat(szDirectoryPath,_TEXT("\\"));
	lstrcat(szDirectoryPath, szDllName);

	TCHAR* szRemoteDllName = NULL;
	LPVOID lpLoadLibrary = NULL;
	HANDLE hRemoteThread = NULL;
	DWORD dwRemote = 0;

	DWORD A = _tcsclen(szDirectoryPath);

	szRemoteDllName = (TCHAR*)VirtualAllocEx(m_hTargetProcess,NULL, sizeof(TCHAR) * _tcsclen(szDirectoryPath), MEM_COMMIT, PAGE_READWRITE);
	if(NULL == szRemoteDllName) 
	{
		CloseHandle(m_hTargetProcess);
		return FALSE;
	}

	if(!WriteProcessMemory(m_hTargetProcess,szRemoteDllName,szDirectoryPath, sizeof(TCHAR) * _tcsclen(szDirectoryPath),NULL)) 
	{
		VirtualFreeEx(m_hTargetProcess,szRemoteDllName, 0, MEM_RELEASE);
		return FALSE;
	}

	lpLoadLibrary = GetProcAddress(GetModuleHandle(_TEXT("KERNEL32.dll")),"LoadLibraryW");
	hRemoteThread = CreateRemoteThread(m_hTargetProcess,NULL,0,(LPTHREAD_START_ROUTINE)lpLoadLibrary,szRemoteDllName,0,NULL);

	if(NULL == hRemoteThread) 
	{
		VirtualFreeEx(m_hTargetProcess,szRemoteDllName,0,MEM_RELEASE);
		CloseHandle(m_hTargetProcess);
		return FALSE;
	}

	WaitForSingleObject(hRemoteThread,INFINITE);
	GetExitCodeThread(hRemoteThread,&dwRemote);
	CloseHandle(hRemoteThread);
	VirtualFreeEx(m_hTargetProcess,szRemoteDllName,0,MEM_RELEASE);
	return TRUE;			
}
Exemple #20
0
BOOL __stdcall 	SharedMemory::recv(PVOID pBuffer, UINT32 milliSeconds)
{
	assert( pBuffer != NULL);
	BOOL bSuccess = FALSE;

	::timeBeginPeriod(this->_pPimpl->wTimerRes);

	if (TRUE == this->_pPimpl->bServer)
	{
		if (WAIT_OBJECT_0 == ::WaitForSingleObject(_pPimpl->hRecvEvent[0], milliSeconds))
		{
			if (WAIT_OBJECT_0 == ::WaitForSingleObject( this->_pPimpl->hMutex, milliSeconds))
			{
				::CopyMemory(pBuffer, this->_pPimpl->pData, this->_pPimpl->size);
				::ReleaseMutex( this->_pPimpl->hMutex);
				bSuccess = TRUE;
			}
            else
				DebugLog(0, _TEXT("kamelas : %s shared memory server recv fail"), _pPimpl->name);
		}
        //else
		//	DebugLog(0, _TEXT("%s shared memory server recv timeout"), _pPimpl->name);            
	}
	else
	{
        DWORD dwRet = 0;
		if (WAIT_OBJECT_0 == (dwRet = ::WaitForSingleObject(_pPimpl->hRecvEvent[1], milliSeconds)) )
		{
			if (WAIT_OBJECT_0 == ::WaitForSingleObject( this->_pPimpl->hMutex, milliSeconds))
			{
				::CopyMemory(pBuffer, this->_pPimpl->pData, this->_pPimpl->size);
				::ReleaseMutex( this->_pPimpl->hMutex);
				bSuccess = TRUE;
			}
            else
				DebugLog(0, _TEXT("kamelas : %s shared memory client recv fail"), _pPimpl->name);
		}
        //else
		//	DebugLog(0, _TEXT("%s shared memory client recv timeout, code = %d"), _pPimpl->name, dwRet);            
	}

	::timeEndPeriod( this->_pPimpl->wTimerRes);
	return bSuccess;	
}
Exemple #21
0
int
main(
	int	argc,
	char	*argv []
	)
{
        LARGE_INTEGER lint;
	DWORD Written;
	COORD Coord = { 0, 0 };

	myself = GetModuleHandle(NULL);

	GetConsoleScreenBufferInfo (GetStdHandle(STD_OUTPUT_HANDLE),
	                            &ScreenBufferInfo);
	ScreenBufferInfo.dwSize.X = ScreenBufferInfo.srWindow.Right - ScreenBufferInfo.srWindow.Left + 1;
	ScreenBufferInfo.dwSize.Y = ScreenBufferInfo.srWindow.Bottom - ScreenBufferInfo.srWindow.Top + 1;
	ScreenBuffer = CreateConsoleScreenBuffer(
			GENERIC_WRITE,
			0,
			NULL,
			CONSOLE_TEXTMODE_BUFFER,
			NULL
			);
	if (INVALID_HANDLE_VALUE == ScreenBuffer)
	{
		_ftprintf(
			stderr,
			_TEXT("%s: could not create a new screen buffer\n"),
			app_name
			);
		return EXIT_FAILURE;
	}
	// Fill buffer with black background
	FillConsoleOutputAttribute( ScreenBuffer,
				    0,
				    ScreenBufferInfo.dwSize.X * ScreenBufferInfo.dwSize.Y,
				    Coord,
				    &Written );

	WaitableTimer = CreateWaitableTimer( NULL, FALSE, NULL );
	if( WaitableTimer == INVALID_HANDLE_VALUE )
	  {
	    printf( "CreateWaitabletimer() failed\n" );
	    return 1;
	  }
	lint.QuadPart = -2000000;
	if( SetWaitableTimer( WaitableTimer, &lint, 200, NULL, NULL, FALSE ) == FALSE )
	  {
	    printf( "SetWaitableTimer() failed: 0x%lx\n", GetLastError() );
	    return 2;
	  }
	SetConsoleActiveScreenBuffer(ScreenBuffer);
	MainLoop();
	CloseHandle(ScreenBuffer);
	return EXIT_SUCCESS;
}
//初始化列表头
void CDlgLianHaoLanQiu::InitListHeader()
{
	CRect Rect;
	//初始化应用程序列表控件
	m_ListCtrl.GetWindowRect(&Rect);
	int nWidth = Rect.Width()/10;
	m_ListCtrl.InsertColumn(0,_TEXT("期数"),    LVCFMT_CENTER,	2*nWidth);
	m_ListCtrl.InsertColumn(1,_TEXT("均值"),	LVCFMT_CENTER,	2*nWidth);
	m_ListCtrl.InsertColumn(2,_TEXT("杀红"),	LVCFMT_CENTER,	6*nWidth);
/*	m_ListCtrl.InsertColumn(2,_TEXT("杀红1"),	LVCFMT_CENTER,	nWidth); 
	m_ListCtrl.InsertColumn(3,_TEXT("杀红2"),	LVCFMT_CENTER,	nWidth);
	m_ListCtrl.InsertColumn(4,_TEXT("杀红3"),	LVCFMT_CENTER,	nWidth);
	m_ListCtrl.InsertColumn(5,_TEXT("杀红4"),	LVCFMT_CENTER,	nWidth);
	m_ListCtrl.InsertColumn(6,_TEXT("杀红5"),	LVCFMT_CENTER,	nWidth);
	m_ListCtrl.InsertColumn(7,_TEXT("杀红6"),	LVCFMT_CENTER,	nWidth);
	m_ListCtrl.InsertColumn(8,_TEXT("杀红7"),	LVCFMT_CENTER,	nWidth);
	m_ListCtrl.InsertColumn(9,_TEXT("杀红8"),	LVCFMT_CENTER,	nWidth);
	*/
}
Exemple #23
0
void CScales::CloseLog()
{
    // если лог открыт
    if (m_LogFile != INVALID_HANDLE_VALUE)
    {
        WriteLogStr("end\n");
        // закрываем его
        CloseHandle(_TEXT("c:\\scale.dmp"));
    }
}
Exemple #24
0
BOOL FileLog::create(SYSTEMTIME st)
{
	if (this->_pPimpl->fstream.is_open())
		this->_pPimpl->fstream.close();

	TCHAR logFileName[MAX_PATH] = {0, };
	TCHAR logFileFullPath[MAX_PATH] = {0, };

	_stprintf (logFileName, _TEXT("%04u%02u%02u.txt"), st.wYear, st.wMonth, st.wDay);
	_tcscpy( logFileFullPath , this->_pPimpl->szPath);
	_tcscat( logFileFullPath , _TEXT("\\"));
	_tcscat( logFileFullPath , logFileName);

	this->_pPimpl->fstream.open( logFileFullPath, std::ios::out | std::ios::app );
	if (! this->_pPimpl->fstream.is_open())
		return false;

	return true;
}
Exemple #25
0
int CPST2ICALApp::StartMigration(_TCHAR* exec)
{
	_TCHAR usage[256];
	HINSTANCE hInst = ::GetModuleHandle(NULL);
	_TCHAR current_method[] = _TEXT("CPST2ICALApp::StartMigration");
	if (IsVerbose()){
		::LoadString(hInst, IDS_ENTER_METHOD, usage, 256);
		::_tprintf(_TEXT("%s %s\n"), usage, current_method);
	}
	m_pstProc->SetVerbose(m_verbose);
	m_xmlProc->SetVerbose(m_verbose);
//	::_tprintf(L"GetServer2: %s\n", exec);
	int retCode = m_pstProc->Start(exec, this);
	if (IsVerbose()){
		::LoadString(hInst, IDS_EXIT_METHOD, usage, 256);
		::_tprintf(_TEXT("%s %s\n"), usage, current_method);
	}
	return retCode;
}
Exemple #26
0
BOOL FormPath(TCHAR *pBuffer, TCHAR *pFolder, TCHAR *pFilename)
{
	if (!pBuffer || !pFolder || !pFilename)
		return FALSE;

	// Init the buffer
	_tcsset(pBuffer, 0);
	_tcscpy(pBuffer, pFolder);
	if (pFolder[_tcslen(pFolder)-1] != _TCHAR('\\'))
	{
		_tcscat(pBuffer, _TEXT("\\"));
	}

	_tcscat(pBuffer, pFilename);
	_tcscat(pBuffer,_TEXT("\0"));

	// Formed the path.. success
	return TRUE;
}
Exemple #27
0
DLlist::DLlist()
{
	m_textTopMargin=4;
	m_textRightMargin=6;
	m_textLeftMargin=4;
	m_itemHeight=0;
	m_oldHotItem=-1;
	m_font.CreateFontW(-12,0,0,0,0,FALSE,FALSE,0,0,0,0,0,0,_TEXT("宋体"));
	m_imgLeftMargin=5;
}
// make the object valid again by trying to get it back
// in a valid state, if not reconcilable, throw an exception
void ValidatedObject::revalidate()
{
		 // nothing to do if already valid
		 if (valid())
			 return;

		 			 DTL_THROW ValidityException(_TEXT("ValidatedObject::revalidate()"), 
			 tstring_cast((tstring *)NULL, STD_::string(typeid(*this).name())),
			 ValidityException::REVALIDATE_FAILED);
}
void mm_load_config_file(void)
{
	if (!*config_file_path) {
		_tcscat(config_file_path, mm_app_data_loc);
		_tcscat(config_file_path, _TEXT("\\config.dat"));
	}
	
	FILE *file = fopen(config_file_path, "r");

	// No mods have been installed previously.
	if (file == NULL)
		return;

	// Read the file version. Currently unused.
	unsigned int version = mm_read_uint(file);

	// Read directories.
	mm_read_string(file, modPath);
	mm_read_string(file, gamePath);
	mm_read_string(file, backupPath);

	// Read the number of previously installed mods.
	unsigned int mod_count = mm_read_uint(file);
	
	for (unsigned int i = 0; i < mod_count; ++i)
	{
		mm_installed_mod *mod = new mm_installed_mod;

		// Load info about the installed mod.
		char file_path[MAX_PATH];
		mm_read_string(file, file_path);

		mod->file_path = mm_str_duplicate(file_path);
		mod->file_crc = mm_read_uint(file);
		mod->file_count = mm_read_uchar(file);

		// Load a list of files the installed mod has modified.
		mod->files = new mm_installed_file[mod->file_count];

		for (unsigned int f = 0; f < mod->file_count; ++f)
		{
			char file_name[MAX_PATH];
			mm_read_string(file, file_name);
			mod->files[f].file_name = mm_str_duplicate(file_name);

			mm_read_string(file, mod->files[f].vehicle_short);
			mod->files[f].flags = mm_read_uchar(file);
			mod->files[f].livery = mm_read_uchar(file);
		}

		installed_mods[num_installed_mods++] = mod;
	}

	fclose(file);
}
//-------------------------------------------------------------------------
LPCTSTR ResetPermissionDialog::GenerateWorkBatchFileName()
{
    // Make temp file name
    static TCHAR CmdFileName[MAX_PATH2] = { 0 };

    // Compute if it was not already computed
    if (CmdFileName[0] == _TCHAR('\0'))
    {
        // Attempt to use local user AppData folder
        if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, CmdFileName)))
        {
            _tcsncat_s(CmdFileName, STR_FOLDER_LALLOUSLAB, _countof(CmdFileName));

            // Work directory note found? Create it!
            if ((GetFileAttributes(CmdFileName) == INVALID_FILE_ATTRIBUTES)
                && !CreateDirectory(CmdFileName, nullptr))
            {
                // Failed to create the folder. Discard the local app folder and use temp folder
                CmdFileName[0] = _T('\0');
            }
        }

        // Revert to temp folder if this fails
        if (CmdFileName[0] == _TCHAR('\0'))
        {
            // Get temp path via the API
            if (GetTempPath(_countof(CmdFileName), CmdFileName) == 0)
            {
                // Attempt to get it again via the environment variable
                if (GetEnvironmentVariable(_TEXT("TEMP"), CmdFileName, _countof(CmdFileName)) == 0)
                    return nullptr;
            }
        }

        if (CmdFileName[_tcslen(CmdFileName) - 1] != TCHAR('\\'))
            _tcsncat_s(CmdFileName, _TEXT("\\"), _countof(CmdFileName));

        _tcsncat_s(CmdFileName, STR_RESET_FN, _countof(CmdFileName));
    }

    return CmdFileName;
}