본문 바로가기
반응형

프레임워크/MFC15

[MFC] 현재 실행파일 경로 불러오기 TCHAR path[_MAX_PATH]; GetModuleFileName(NULL, path, sizeof path); CString strPath1 = path; int i = strPath1.ReverseFind('\\');//실행 파일 이름을 지우기 위해서 왼쪽에 있는 '/'를 찾는다. strPath1 = strPath1.Left(i); AfxMessageBox(strPath1); 2022. 4. 11.
[MFC/WinAPI] process id 이용하여 윈도우 HWDN 얻기. 프로세스 아이디를 이용하여 윈도우의 핸들을 얻기 위한 방법. HWND GetHwndFromPid(DWORD pid) { HWND temp = FindWindow(NULL, NULL); while (temp != NULL) { if (::GetParent(temp) != NULL) { DWORD idproc; GetWindowThreadProcessId(temp, &idproc); if (pid == idproc) { return temp; } } temp = ::GetWindow(temp, GW_HWNDNEXT); } } HWDN는 윈도우의 핸들을 말한다. 2021. 12. 8.
[MFC] Ctrl 키 입력 MFC 에서 키입력이 필요한 부분이 있어 찾아 보고 정리 ※ 코드 BOOL CKeyDownDlg::PreTranslateMessage(MSG* pMsg) { if(pMsg->message == WM_KEYDOWN ) { if(pMsg->wParam == VK_CONTROL) { AfxMessageBox(_T("Ctrl Key Down")); } } return CChildDialog::PreTranslateMessage(pMsg); } ※ 출력 결과 2021. 9. 8.
[MFC] 파일 입출력, CFile, CStdioFile CFileCFile 이용하여 파일 Write 하는 법CFile file;vector vServiceTest;for( int i = 0; i   CFile 이용해서 파일 Read 하는 법  //읽어올 파일 경로 불러오기CString strDefaultPath = _T("");CFileDialog pDlg(TRUE, _T("Files (*.txt)"), NULL, OFN_FILEMUSTEXIST | // 존재하는 파일만 선택 가능 OFN_PATHMUSTEXIST | // 존재하는 경로만 선택 가능 OFN_HIDEREADONLY | // ReadOnly 체크박스 숨김 OFN_LONGNAMES //긴 파일 이름 포맷 지원 , _T("Files (*.txt)|*.txt|All Files (*.*).. 2021. 8. 4.
반응형