..
CString CurrentDirectoryToCString() { TCHAR buff[MAX_PATH]; memset(buff, 0, MAX_PATH); ::GetCurrentDirectory(MAX_PATH, buff); CString strFolder = buff; return strFolder; }..
CString CurrentDirectoryToCString() { TCHAR buff[MAX_PATH]; memset(buff, 0, MAX_PATH); ::GetCurrentDirectory(MAX_PATH, buff); CString strFolder = buff; return strFolder; }..
char text[] = "something";
wchar_t wtext[20];
mbstowcs(wtext, text, strlen(text)+1);//Plus null
LPWSTR ptr = wtext;
TCHAR Tch[MAX_PATH + 1]; int lenOftch = (wcslen(Tch) + 1) * 2; char * pStrTch = (char*)malloc(sizeof(char)*MAX_PATH); //tchar* to char* WideCharToMultiByte(CP_UTF8, 0, Tch, -1, pStrTch, lenOftch, NULL, NULL);//
char charBuff[]="test"; TCHAR szUniCode[256]={0,}; MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, charBuff, strlen(charBuff), szUniCode, 256);
string s; CString cs(s.c_str()); //< - lpctstr
... if (m_Manual_shell_hadle != NULL) { unsigned int tmp_pid = GetProcessId(m_Manual_shell_hadle); // retrieve PID //It comes under the pid value to the storage handle. Take on only kill pid is the same as the saved pid. if (tmp_pid == m_Manual_shell_pid) { TerminateProcess(m_Manual_shell_hadle, 1); //kill process m_Manual_shell_hadle = NULL; return 1; //sucess } } m_Manual_shell_hadle = NULL; return 0; //not found ......
... SHELLEXECUTEINFO ShExecInfo = { 0 }; ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; ShExecInfo.hwnd = this->m_hWnd; ShExecInfo.lpVerb = NULL; ShExecInfo.lpFile = TargetPath; //external file name ShExecInfo.lpParameters = NULL; //aguments ShExecInfo.lpDirectory = NULL; ShExecInfo.nShow = SW_SHOW; ShExecInfo.hInstApp = NULL; ShellExecuteEx(&ShExecInfo); //execute //save pid and handle m_Manual_shell_pid = GetProcessId(ShExecInfo.hProcess); // retrieve PID m_Manual_shell_hadle = ShExecInfo.hProcess; ......
::BringWindowToTop(hwnd); ::SetActiveWindow(hwnd); ::SetForegroundWindow(hwnd); ::ShowWindow(hwnd, SW_SHOWNORMAL); ::UpdateWindow(hwnd);///
HWND g_HWND = NULL; BOOL CALLBACK EnumWindowsProcMy(HWND hwnd, LPARAM lParam) { DWORD lpdwProcessId; GetWindowThreadProcessId(hwnd, &lpdwProcessId); if (lpdwProcessId == lParam) { g_HWND = hwnd; return FALSE; } return TRUE; } int CSomeClass::ActiveManualWindowIfAlive() { if (m_Manual_shell_hadle != NULL) { unsigned int tmp_pid = GetProcessId(m_Manual_shell_hadle); // retrieve PID if (tmp_pid == m_Manual_shell_pid) { g_HWND = NULL; EnumWindows(EnumWindowsProcMy, m_Manual_shell_pid); if (g_HWND != NULL) { ::BringWindowToTop(g_HWND); return 1; } } } return 0; }