BOOL CIniFile::WriteIniFile() { m_bFileExist = IniFile.Open(m_sFileName, CFile::modeCreate| CFile::modeWrite); if(!m_bFileExist) return FALSE; CString strline; TCHAR* old_locale = _tcsdup( _tsetlocale(LC_CTYPE,NULL) ); _tsetlocale( LC_CTYPE, _T("chs")); //将FileContainer写到IniFile文件 for(int i = 0; i< FileContainer.GetSize(); i++) { strline = FileContainer[i]; IniFile.WriteString(strline+_T("\n")); } IniFile.Close(); _tsetlocale( LC_CTYPE, old_locale ); free( old_locale ); return m_bFileExist; }
BOOL CIniFile::ReadIniFile() { m_bFileExist = IniFile.Open(m_sFileName, CFile::modeRead); TCHAR* old_locale = _tcsdup( _tsetlocale(LC_CTYPE,NULL) ); _tsetlocale( LC_CTYPE, _T("chs")); if(!m_bFileExist) { return FALSE; } CString strline; FileContainer.RemoveAll(); //将IniFile文件数据读到FileContainer while(IniFile.ReadString(strline)) { FileContainer.Add(strline); } IniFile.Close(); _tsetlocale( LC_CTYPE, old_locale ); free( old_locale ); return TRUE; }
void lc_print(LPCTSTR lpszLocale,LPCTSTR lpszFormat,...){ va_list args; // va_start(args,lpszFormat); #if defined(_UNICODE) LPCTSTR lpszSvLc = _tsetlocale(LC_ALL,NULL); _tsetlocale(LC_ALL,lpszLocale); _vtprintf(lpszFormat,args); _tsetlocale(LC_ALL,lpszSvLc); #else oem_vprint(lpszFormat,args); #endif va_end(args); }
void CTeapotApp::InitLocale() { #define _USE_CRT_LOCALE #if _MSC_VER > 1400 #define _USE_IOS_LOCALE #endif // CRT 全局 locale 和 iostream imbue locale 冲突 // VC 2005 问题 (_MSC_VER = 1400) // VC 2010 正常 (_MSC_VER = 1600) #if _MSC_VER <= 1400 && defined(_USE_CRT_LOCALE) && defined(_USE_IOS_LOCALE) #error cannot use CRT global locale and iostream imbue locale at the same time, when _MSC_VER <= 1400 #endif #ifdef _USE_CRT_LOCALE _tsetlocale(LC_ALL, _T("")); #endif #ifdef _USE_IOS_LOCALE // 设置 C++ iostream 标准 IO 流 locale std::locale loc(std::locale(""), std::locale::classic(), std::locale::numeric); std::cout.imbue(loc); std::cerr.imbue(loc); std::cin.imbue(loc); #endif }
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) { _tsetlocale(LC_CTYPE, L""); //make CRT character handling functions handle not only C string (lower/upper case funcs) //maybe we need also to tell the compiler how to handle its chars (http://msdn.microsoft.com/en-us/library/3e22ty2t.aspx) // If you are running on NT 4.0 or higher you can use the following call instead to // make the EXE free threaded. This means that calls come in on a random RPC thread. HRESULT hRes = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); //new call ATLASSERT(SUCCEEDED(hRes)); // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used ::DefWindowProc(NULL, 0, 0, 0L); AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls // GDI+ initialization ULONG_PTR gdiplusToken; Gdiplus::GdiplusStartupInput gdiplusStartupInput; Gdiplus::Status gdiPlusStatus = GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); ATLASSERT( gdiPlusStatus==Gdiplus::Ok ); hRes = _Module.Init(NULL, hInstance); ATLASSERT(SUCCEEDED(hRes)); srand(::GetTickCount()); int nRet = Run(lpstrCmdLine, nCmdShow); // GDI+ deinitialization GdiplusShutdown(gdiplusToken); _Module.Term(); ::CoUninitialize(); return nRet; }
int _tmain(int argc, _TCHAR* argv[]) { _tsetlocale(LC_ALL, _T("korean")); DWORD isExit; if (argc >= 2) { tokenNum = argc - 1; for (int i = 1; i < argc; i++) { _tcscpy(cmdTokenList[i - 1], argv[i]); } CmdProcessing(); } while (1) { if (!Tokenize()) { continue; } isExit = CmdProcessing(); if (isExit == TRUE) { _fputts(_T("명령어 처리를 종료합니다. \n"), stdout); break; } tokenNum = 0; } return 0; }
//----------------------------------------------------------------------------- // プログラム スタート //----------------------------------------------------------------------------- int _tmain(int argc, TCHAR** argv) { _tsetlocale(LC_ALL, _T("japanese")); if (argc == 2) { cDrv = argv[1][0]; } TCHAR stressPath[MAX_PATH]; _stprintf(stressPath, _T("%c:\\__hddstress__"), cDrv); TCHAR readPath[MAX_PATH]; _stprintf(readPath, _T("%c:\\"), cDrv); // Ctrl+C でしか止まりません。 for (;;) { // ストレステスト用ファイルを作成するフォルダを準備 _tmkdir(stressPath); // ストレステスト用のファイルを作成 MakeAll(stressPath); // 全ファイルを読み込むテスト ReadAll(readPath); _putts(_T("")); } return 0; }
virtual void OnRequest(IIPCObject* pServer, IIPCConnector* pClient, LPCVOID lpBuf, DWORD dwBufSize) { if(NULL == lpBuf || dwBufSize == 0) return ; LPUSER_DATA_PACKAGE userRequest = (LPUSER_DATA_PACKAGE)lpBuf; _tsetlocale(LC_ALL, _T("chs")); _tprintf_s(_T("%s"), userRequest->lpBuf); if(userRequest->dwPackageType == 100) { TCHAR sReply[MAX_PATH] = {0}; _stprintf_s(sReply, _T("同步应答:1+1=2 \r\n")); _USER_DATA_PACKAGE userRequest = {0}; userRequest.dwPackageType = 100; _tcscpy_s(userRequest.lpBuf, MAX_PATH, sReply); pClient->PostMessage(&userRequest, sizeof(_USER_DATA_PACKAGE)); } else { TCHAR sReply[MAX_PATH] = {0}; _stprintf_s(sReply, _T("异步应答:你好,客户端 \r\n")); _USER_DATA_PACKAGE userRequest = {0}; userRequest.dwPackageType = 1; _tcscpy_s(userRequest.lpBuf, MAX_PATH, sReply); pClient->PostMessage(&userRequest, sizeof(_USER_DATA_PACKAGE)); } }
int _tmain(int argc, _TCHAR* argv[]) { _tsetlocale(LC_ALL, _T("")); Arguments argument; if ( argument.parseArgs(argc, argv)) { ECGConverter::usage(argv[0]); return -1; } int status = argument.convertToWave(); if (status != ERR_OK) { std::cerr << "Error Internal cannot convert MP3 to WAV\n"; return -1; } Convert2ECG converter; status = converter.convert(argument); converter.outStatus(argument, status); argument.delteWaveFile(); if (argument.opt_v) { std::cerr << "\n\tlast status:" << status << "\n"; } return status; }
Ui::Ui() { controls["TotalProgressBar"] = NULL; controls["FileProgressBar"] = NULL; controls["TotalDownloaded"] = NULL; controls["FileDownloaded"] = NULL; controls["FileName"] = NULL; controls["Speed"] = NULL; controls["Status"] = NULL; controls["ElapsedTime"] = NULL; controls["RemainingTime"] = NULL; controls["NextButton"] = NULL; controls["BackButton"] = NULL; controls["WizardForm"] = NULL; controls["WizardPage"] = NULL; controls["LabelFont"] = NULL; //Graphical Installer controls["GINextButton"] = NULL; controls["GIBackButton"] = NULL; //HACK to call idpReportError in main thread controls["InvisibleButton"] = NULL; allowContinue = false; hasRetryButton = true; detailedMode = false; redrawBackground = false; errorDlgMode = DLG_SIMPLE; dllHandle = NULL; _tsetlocale(LC_ALL, _T("")); }
void TestRequestAndReply(IIPCObject* pNamedPipeClient) { IIPCConnectorIterator* pClientIterator = pNamedPipeClient->GetClients(); while(FALSE == g_bExit) { for(pClientIterator->Begin(); !pClientIterator->End(); pClientIterator->Next()) { IIPCConnector* aClient = pClientIterator->GetCurrent(); if(NULL == aClient) continue; TCHAR* sRequest = _T("1+1=2\r\n"); DWORD dwRequestSize = _tcslen(sRequest) * sizeof(TCHAR); DWORD dwTransSize = 0; TCHAR sReply[MAX_PATH] = {0}; if(aClient->RequestAndReply(sRequest, dwRequestSize, sReply, MAX_PATH, &dwTransSize)) { _tsetlocale(LC_ALL, _T("chs")); _tprintf_s(_T("%s"), sReply); } } } }
BOOL CNotepadApp::InitInstance() { _tsetlocale(LC_ALL, _T("")); // Standard initialization LoadStdProfileSettings(8); // Load standard INI file options (including MRU) // Register document templates CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CNotepadDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CNotepadView)); AddDocTemplate(pDocTemplate); // open file specified on command line if (m_lpCmdLine[0] == 0) OnFileNew(); else OpenDocumentFile(m_lpCmdLine); return TRUE; }
int WINAPI _tWinMain( HINSTANCE hInst, HINSTANCE, LPTSTR, int ) { _tsetlocale( LC_ALL, _T(".OCP") ); ATLVERIFY( SUCCEEDED( _Module.Init( NULL, hInst ) ) ); if( !EnableDebugPrivilege() ) { MessageBoxV( NULL, IDS_NO_DEBUG_PRIVILEGE, MB_OK | MB_ICONHAND ); return 0; } InitializeCriticalSection( &g_cs ); LoadInternalExceptionList(); LoadSettings(); DumpInit(); if( !ProcessCommandLine() ) { AtlInitCommonControls( ICC_BAR_CLASSES ); LoadLibrary( CRichEditCtrl::GetLibraryName() ); CMainDlg dlgMain; g_pMainWnd = &dlgMain; int nRet = dlgMain.DoModal(); g_pMainWnd = NULL; } DumpUninit(); SaveSettings(); DeleteCriticalSection( &g_cs ); _Module.Term(); return 0; }
int _tmain(int argc, TCHAR * argv[]) { // 한글 입력을 가능케 하기 위해. _tsetlocale(LC_ALL, _T("Korean")); if (argc >= 2) // 매개변수 전달인자가 있는 경우. { for (int i = 1; i<argc; i++) _tcscpy_s(cmdTokenList[i - 1], argv[i]); CmdProcessing(argc - 1); } int isExit = NULL; while (1) { int tokenNum = CmdReadTokenize(); if (tokenNum == 0) //Enter 입력시 처리를 위해... continue; isExit = CmdProcessing(tokenNum); if (isExit == TRUE) { _fputts(_T("명령어 처리를 종료합니다. \n"), stdout); break; } } return 0; }
BOOL CMainApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); g_Profile.Init(theApp); AfxEnableControlContainer(); // 创建 shell 管理器,以防对话框包含 // 任何 shell 树视图控件或 shell 列表视图控件。 CShellManager *pShellManager = new CShellManager; // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); _tsetlocale(LC_CTYPE, _T("chs")); AfxInitRichEdit2(); CMainDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 在此放置处理何时用 // “确定”来关闭对话框的代码 } else if (nResponse == IDCANCEL) { // TODO: 在此放置处理何时用 // “取消”来关闭对话框的代码 } // 删除上面创建的 shell 管理器。 if (pShellManager != NULL) { delete pShellManager; } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; }
BOOL CDBFExplorerApp::InitInstance() { _tsetlocale(LC_ALL, _T("")); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. InitCommonControls(); #ifndef _WIN64 AfxDaoInit(); #endif // Change the registry key under which our settings are stored. SetRegistryKey(_T("Pablo Software Solutions")); LoadStdProfileSettings(max(_AFX_MRU_COUNT, 9)); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. AddDocTemplates(); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE | FWS_PREFIXTITLE)) return FALSE; m_pMainWnd = pMainFrame; // Enable drag/drop open m_pMainWnd->DragAcceptFiles(); // Enable DDE Execute open EnableShellOpen(); #ifdef _DEBUG RegisterShellFileTypes(TRUE); #endif // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; // prevent application from opening a new (empty) document //cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; ParseCommandLine(cmdInfo); if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew) cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; m_nCmdShow = SW_SHOWMAXIMIZED; // The main window has been initialized, so show and update it. pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; }
CMainWizard::CMainWizard(CWnd* pOwnerWnd): CCustomPropSheet(AFX_IDS_APP_TITLE, pOwnerWnd) { CUpdateItApp* pApp = DYNAMIC_DOWNCAST(CUpdateItApp, AfxGetApp()); ASSERT_VALID(pApp); // assign CRT locale static const TCHAR szDefLocale[] = _T("English_USA.1252"); _tsetlocale(LC_ALL, pApp->GetProfileString(SZ_REGK_LOCALE, SZ_REGV_LOCALE_LC_ALL, szDefLocale)); // load dialog's icons m_hIcon = pApp->LoadIcon(IDI_APP_ICON); m_hSmIcon = pApp->LoadSmIcon(MAKEINTRESOURCE(IDI_APP_ICON)); static HYPERLINKCOLORS linkColors = { RGB(0, 0, 255), // default RGB(0, 0, 255), // active RGB(0, 0, 255), // visited RGB(255, 0, 0) // hover }; CHyperLink::SetColors(linkColors); ATL::CRegKey regKeyLangs; regKeyLangs.Attach(pApp->GetSectionKey(SZ_REGK_LANGUAGES)); int nError = ERROR_SUCCESS; if (static_cast<HKEY>(regKeyLangs) != NULL) { TCHAR szLangNames[128] = { 0 }; ULONG cchNamesMax = _countof(szLangNames); nError = regKeyLangs.QueryStringValue(NULL, szLangNames, &cchNamesMax); if (nError == ERROR_SUCCESS) { LPCTSTR pszSeps = _T(",;\x20"); LPTSTR pszCurLex = _tcstok(szLangNames, pszSeps); while (pszCurLex != NULL) { m_arrLangNames.Add(pszCurLex); pszCurLex = _tcstok(NULL, pszSeps); } } ::RegCloseKey(regKeyLangs.Detach()); } g_fRestartInterface = false; AddPage(&m_pageAbout); AddPage(&m_pageFirstLaunch); AddPage(&m_pageOptions); AddPage(&m_pageFiles); AddPage(&m_pageAction); AddPage(&m_pageProgress); SetWizardMode(); }
TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2) { int i, j, k; _tsetlocale(LC_ALL, _T("")); for (i=0;s1[i];i++) for (j = i, k = 0; _totlower(s1[j]) == _totlower(s2[k]);j++, k++) if (!s2[k+1]) return (TCHAR*)(s1 + i); return NULL; }
BOOL CSqlqueryApp::InitInstance() { _tsetlocale(LC_CTYPE ,""); BOOL bInit = COleControlModule::InitInstance(); if (bInit) { AfxEnableControlContainer(); TaskAnimateInitialize(); m_strInstallationID = INGRESII_QueryInstallationID(); } return bInit; }
BOOL CLocale::SetLocale(LCID LocaleID) { TCHAR Buf[4]; if (GetLocaleInfo(LocaleID, LOCALE_SABBREVLANGNAME, Buf, sizeof(Buf))) { TCHAR *LocName = _tsetlocale(LC_ALL, Buf); if (LocName) { m_csLocaleName = LocName; m_LocaleID = LocaleID; } } return (LocaleID == m_LocaleID); }
int _tmain(int argc, _TCHAR* argv[]) { _tsetlocale(LC_ALL, _T("Russian")); int c = 0; while (c != 7) { _tprintf(_T("\n======================= Menu ==========================\n\n")); _tprintf(_T("1. Task1 (32bit time)\n")); _tprintf(_T("2. Task2 (GetSystemTimePreciseAsFileTime, GetTickCount accuracy)\n")); _tprintf(_T("3. Task3 (__rdtsc, QueryPerformanceCounter for array summing)\n")); _tprintf(_T("4. Task4 (T(200000)/T (100000), T(300000)/T (100000))\n")); _tprintf(_T("5. Task5.1 (matrix multiplying with class)\n")); _tprintf(_T("6. Task5.2 (matrix multiplying without class)\n")); _tprintf(_T("Print operation: ")); _tscanf_s(_T("%d"), &c); switch (c) { case 1: _tprintf(_T("\n======================= Task 1 ==========================\n\n")); taskOne(); break; case 2: _tprintf(_T("\n======================= Task 2 ==========================\n\n")); taskTwo(); break; case 3: _tprintf(_T("\n======================= Task 3 ==========================\n\n")); taskThree(); break; case 4: _tprintf(_T("\n======================= Task 4 ==========================\n\n")); taskFour(); break; case 5: _tprintf(_T("\n======================= Task 5.1 ==========================\n\n")); taskFiveWithClass(); break; case 6: _tprintf(_T("\n======================= Task 5.2 ==========================\n\n")); taskFiveWithoutClass(); break; } _tprintf(_T("\n")); } return 0; }
void CDlgNote::OnNMClickListTitle(NMHDR *pNMHDR, LRESULT *pResult) { LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR); // TODO: 在此添加控件通知处理程序代码 if(pNMItemActivate->iItem != -1) { m_Edit_strContent=_T(""); CString strFilePath; strFilePath=m_List_ctlTitle.GetItemText(pNMItemActivate->iItem, 1); m_Edit_strTitle=m_List_ctlTitle.GetItemText(pNMItemActivate->iItem, 0); _tsetlocale(LC_ALL, _T("chs")); CStdioFile file; CString strLine=_T(""); CString strText=_T(""); if(file.Open(strFilePath,CFile::modeRead)==TRUE) { while( file.ReadString( strLine )) { strText= strText+strLine+_T("\r\n"); } file.Close(); m_Edit_strContent=strText; } m_Button_ctlSave.EnableButton(TRUE); m_Button_ctlCancel.EnableButton(TRUE); m_Button_ctlSave.Invalidate(TRUE); m_Button_ctlCancel.Invalidate(TRUE); UpdateData(FALSE); } *pResult = 0; }
Console::Console(DWORD handle_type): m_handle(::GetStdHandle(handle_type)), m_is_redirected(false), m_orig_colors(0), io_buffer_size(2048) #ifdef UNICODE ,m_ansi_mode(false) #endif { #ifdef _DEBUG //VS2015でビルドすると、環境によっては_tsetlocale()でハングアップしてしまう? _tsetlocale(LC_ALL,_tsetlocale(LC_CTYPE,_T(""))); #endif { //リダイレクトされているかどうか DWORD mode=0; CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info; m_is_redirected=(handle_type==STD_INPUT_HANDLE)? !getConsoleMode(&mode) :!::GetConsoleScreenBufferInfo(m_handle,&screen_buffer_info); m_orig_colors=getColors(); } }
BOOL CSvriiaApp::InitInstance() { m_strInstallationID = INGRESII_QueryInstallationID(); m_pServer = new CaComServer(); m_pServer->m_hInstServer = m_hInstance; _tsetlocale(LC_CTYPE ,""); _tsetlocale(LC_COLLATE ,""); BOOL bOk = CWinApp::InitInstance(); if (bOk) { bOk = TaskAnimateInitialize(); if (!bOk) { // // Failed to load the dll %1. CString strMsg; AfxFormatString1(strMsg, IDS_FAIL_TO_LOAD_DLL, _T("<TkAnimat.dll>")); AfxMessageBox (strMsg); return FALSE; } } m_userData4GetRow.InitResourceString(); return bOk; }
///////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////// Função DllMain /////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved ) { BOOL Result = TRUE; _tsetlocale(LC_ALL, _T("portuguese_portugal")); switch (fdwReason) { case DLL_PROCESS_ATTACH: // A DDL está a ser mapeada no espaço de endereçamento do processo _tprintf(_T("LoggerDLL.dll: A DDL está a ser mapeada no espaço de endereçamento do processo\n")); _tprintf(_T("0x%p\n"), hinstDLL); if ((tlsIDX = TlsAlloc()) == -1) { Result = FALSE; break; } //Atribuir espaço na entrada do thread corrente Result = _TlsInit() != NULL; break; case DLL_THREAD_ATTACH: // Está a ser criada uma thread _tprintf(_T("LoggerDLL.dll: Está a ser criada uma thread\n")); //Atribuir espaço na entrada TLS do thread corrente _TlsInit(); break; case DLL_THREAD_DETACH: // Existe uma thread a terminar (sem ser através do TerminateThread _tprintf(_T("LoggerDLL.dll: Existe uma thread a terminar (sem ser através do TerminateThread)\n")); //Libertar espaço ocupado pelo thread na entrada TLS _TlsClose(); break; case DLL_PROCESS_DETACH: // A DLL está a ser desmapeada do espaço de endereçamento do processo _tprintf(_T("LoggerDLL.dll: A DLL está a ser desmapeada do espaço de endereçamento do processo\n")); //Libertar espaço ocupado pelo thread na entrada TLS _TlsClose(); //Fechar a entrada de TLS no processo if( !TlsFree(tlsIDX) ) Result = FALSE; break; default: _tprintf(_T("LoggerDLL.dll: DllMain chamada com um motivo desconhecido (%ld)\n"), fdwReason); Result = FALSE; } return Result; // Utilizado apenas para DLL_PROCESS_ATTACH }
int _tmain(int argc, _TCHAR* argv[]) { _tsetlocale(LC_ALL, _T("Russian")); int result = sizeof(TCHAR); if (result == 2) printf("%s. Size of TCHAR = %d\n", "UNICODE", sizeof(TCHAR));//2 bytes else printf("%s. Size of TCHAR = %d\n", "ANSI", sizeof(TCHAR)); //1 byte char Names[2][35] = { "Васильев Дмитрий Геннадиевич", "Журавок Алексей Геннадиевич" }; // 2 строки по 35 символов максимум for (int i = 0; i < sizeof(Names) / sizeof(Names[0]); i++) printf("%s\n", Names[i]); for (int i = 0; i < sizeof(Names) / sizeof(Names[0]); i++) //MultiByteToWideChar(); ; }
//////////////////////////////////////////////////////////////////////////////////////// /// // /// WindowMonitorThreadProc(LPVOID arg); // /// // //////////////////////////////////////////////////////////////////////////////////////// static DWORD WINAPI WindowMonitorThreadProc(LPVOID arg) { MSG msg ; _tsetlocale(LC_CTYPE, _T("")); MSG_DISPLAY_HOOK = RegisterWindowMessage(DISPLAY_HOOK_MSG); if (EnumWindows(EnumWindowsProc,NULL)==FALSE) { printf("Could not save all previously opened windows\n"); } HookHiddenWindow=AllocateWindow(NULL,WndProc); PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); if (HookHiddenWindow==NULL) { printf("Can't allocate window\n"); return(0); } if (HookDisplayFptr(HookHiddenWindow->WindowHandle)) { BOOL bRet; printf("Display Hooked\n"); fflush(stdout); SetEvent(ThreadReady); SetTimer(HookHiddenWindow->WindowHandle,0xBEEF,1000,(TIMERPROC) NULL); while (1) { bRet=GetMessage (&msg, NULL, 0, 0); if ((bRet != -1) && (bRet!=0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } else if ((bRet==0)&&(msg.wParam==0xDEADBEEF)) break; } KillTimer(HookHiddenWindow->WindowHandle,0xBEEF); if (UnhookDisplayFptr(HookHiddenWindow->WindowHandle)) { printf("Display Unhooked\n"); fflush(stdout); } FreeWindow(HookHiddenWindow); DeleteAllWindows(); } else SetEvent(ThreadReady); // FIX ME should use timeout return 0; }
bool initialize(bool i_isYamy) { #ifndef NDEBUG _TCHAR path[GANA_MAX_PATH]; GetModuleFileName(NULL, path, GANA_MAX_PATH); _tsplitpath_s(path, NULL, 0, NULL, 0, g.m_moduleName, GANA_MAX_PATH, NULL, 0); if (_tcsnicmp(g.m_moduleName, _T("Dbgview"), sizeof(_T("Dbgview"))/sizeof(_TCHAR)) != 0 && _tcsnicmp(g.m_moduleName, _T("windbg"), sizeof(_T("windbg"))/sizeof(_TCHAR)) != 0) { g.m_isLogging = true; } #endif // !NDEBUG #ifdef HOOK_LOG_TO_FILE _TCHAR logFileName[GANA_MAX_PATH]; GetEnvironmentVariable(_T("USERPROFILE"), logFileName, NUMBER_OF(logFileName)); _tcsncat(logFileName, _T("\\AppData\\LocalLow\\yamydll.txt"), _tcslen(_T("\\AppData\\LocalLow\\yamydll.log"))); g.m_logFile = CreateFile(logFileName, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); #endif // HOOK_LOG_TO_FILE WriteToLog("try to open mailslot\r\n"); g.m_hMailslot = CreateFile(NOTIFY_MAILSLOT_NAME, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, (SECURITY_ATTRIBUTES *)NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL); if (g.m_hMailslot == INVALID_HANDLE_VALUE) { HOOK_RPT2("MAYU: %S create mailslot failed(0x%08x)\r\n", g.m_moduleName, GetLastError()); WriteToLog("open mailslot NG\r\n"); } else { HOOK_RPT1("MAYU: %S create mailslot successed\r\n", g.m_moduleName); WriteToLog("open mailslot OK\r\n"); } if (!mapHookData(i_isYamy)) return false; _tsetlocale(LC_ALL, _T("")); g.m_WM_MAYU_MESSAGE = RegisterWindowMessage(addSessionId(WM_MAYU_MESSAGE_NAME).c_str()); g.m_hwndTaskTray = g_hookData->m_hwndTaskTray; if (!i_isYamy) { NotifyThreadAttach ntd; ntd.m_type = Notify::Type_threadAttach; ntd.m_threadId = GetCurrentThreadId(); notify(&ntd, sizeof(ntd)); } g.m_isInitialized = true; return true; }
BOOL CMiniCalendarApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); AfxEnableControlContainer(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 AfxInitRichEdit(); SetRegistryKey(_T("应用程序向导生成的本地应用程序")); _tsetlocale(LC_ALL, _T("Chinese-simplified")); CMiniCalendarDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 在此放置处理何时用 // “确定”来关闭对话框的代码 } else if (nResponse == IDCANCEL) { // TODO: 在此放置处理何时用 // “取消”来关闭对话框的代码 } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; }
void CPreferences::SetRtlLocale(LCID lcid) { const SLanguage* pLangs = _aLanguages; while (pLangs->lid) { if (pLangs->lid == LANGIDFROMLCID(lcid)) { if (pLangs->uCodepage) { CString strCodepage; strCodepage.Format(_T(".%u"), pLangs->uCodepage); _tsetlocale(LC_CTYPE, strCodepage); } break; } pLangs++; } }