본문 바로가기
반응형

c++11

dbus 로 서비스 실행하기 inline static int freeDbusValue(int ret, sd_bus_error error, sd_bus_message *m, sd_bus *bus) { sd_bus_error_free(&error); sd_bus_message_unref(m); sd_bus_unref(bus); return ret; } int DBusUtility::executeService(const std::string &serviceName) { if (serviceName.empty()) { ERROR_PRINT("DBusUtility::executeService Failed: serviceName is empty"); return EXIT_FAILURE; } DEBUG_PRINT("DBusUtility::exe.. 2023. 12. 27.
c++ 폴더 내의 파일 갯수 체크 출처: https://www.reddit.com/r/cpp_questions/comments/ms5ued/getting_filecount_of_a_directory_windows_10/?rdt=35812 size_t getNumberOfFilesInDirectoryRecursively(std::filesystem::path path) { size_t count = 0; std::filesystem::recursive_directory_iterator iterator(path, std::filesystem::directory_options::skip_permission_denied); for (auto& entry : iterator) { if (std::filesystem::is_regular_file(.. 2023. 12. 19.
How to perform chmod recursively? 출처: https://stackoverflow.com/questions/71249234/how-to-perform-chmod-recursively #include #include // see notes about these two lines at the bottom namespace fs = std::filesystem; // -"- void chmodr(const fs::path& path, fs::perms perm) { fs::permissions(path, perm); // set permissions on the top directory for(auto& de : fs::recursive_directory_iterator(path)) { fs::permissions(de, perm); // se.. 2023. 12. 19.
탁월한 프로그래머가 되려면.. 탁월한 프로그래머가 되기 위해서는 몇 가지 요소가 필요합니다. 여기에 몇 가지 팁을 알려드리겠습니다: 1. 학습과 지속적인 개선: 프로그래밍 언어, 알고리즘, 데이터 구조 등 프로그래밍 기초를 공부하고 학습하는 것이 중요합니다. 계속해서 새로운 기술과 개발 도구에 대한 지식을 습득하고 개인적으로 발전하는 노력을 기울이세요. 2. 실전 프로젝트 경험: 이론적인 지식뿐만 아니라 실제 프로젝트에 참여하여 경험을 쌓는 것이 중요합니다. 개인 프로젝트를 시작하거나 오픈 소스 프로젝트에 기여하는 등 다양한 경험을 쌓아보세요. 3. 문제 해결 능력: 프로그래머는 문제를 해결하기 위해 논리적인 사고와 창의성이 필요합니다. 문제 해결 능력을 향상시키기 위해 알고리즘 문제를 풀거나 코딩 퍼즐에 도전해보세요. 4. 협업과 .. 2023. 10. 24.
객체에서 std::shared_ptr 얻기 std::shared_ptr pSharedPtr = std::make_shared(std::move(classObject)); 2023. 8. 7.
lambda expression 람다 식은 c++ 11 이상에서 지원된다. 이름없는 함수 객체를 정의하는 편리한 방법이다. 위 그림은 람다 식이 어떻게 구성되어 있는지 보여준다. 1번과 6번만이 필수이다. capture clause (Also known as the lambda-introducer in the C++ specification.) parameter list Optional. (Also known as the lambda declarator) mutable specification Optional. exception-specification Optional. trailing-return-type Optional. lambda body. 다음은 람다식의 예제이다. auto lamdaFunc = [](int &a) { n +=.. 2020. 9. 26.
[MFC] Shared Folder 찾아서 제거하기 #include #include #pragma comment(lib, "Netapi32.lib") PSHARE_INFO_502 BufPtr; NET_API_STATUS res; LPTSTR lpszServer = NULL; DWORD er = 0, tr = 0, resume = 0; DWORD total = 0; do { res = NetShareEnum(lpszServer, 502, (LPBYTE *)&BufPtr, MAX_PREFERRED_LENGTH, &er, &tr, &resume); if (res == ERROR_SUCCESS || res == ERROR_MORE_DATA) { total += er; PSHARE_INFO_502 p = BufPtr; DWORD i = 0; for (i = 1; .. 2017. 1. 16.
[MFC] 시작프로그램에 등록하기 시작 프로그램에 등록하는 방법으로 크게 레지스트리를 사용하는 방법과 ShellLink 를 이용한 방법이다. 여기서 소개하는 방법은 2번째 방법이다. void CreateStartupShortcut(void) { HRESULT hRes = NULL; hRes = CoInitialize(NULL); TCHAR FullPath[MAX_PATH] = {0,}; ::GetModuleFileName(NULL, FullPath, _countof(FullPath)); TCHAR StartUpPath[MAX_PATH]= {0,}; BOOL bRes = SHGetSpecialFolderPath(GetSafeHwnd(), StartUpPath, CSIDL_STARTUP, 0); CString StrShortCut = Sta.. 2016. 10. 27.
[MFC] 심플한 로그 함수 #include "stdafx.h" namespace DEBUGLOG { CString LogPath; } int WriteLog(LPCTSTR pFormat, ...) { TCHAR Buff[1024] = {0,}; va_list arg; va_start(arg, pFormat); _vstprintf_s(Buff, _countof(Buff) - 1, pFormat, arg); va_end(arg); SYSTEMTIME lpSystemTime; GetLocalTime(&lpSystemTime); COleDateTime CurSysTime(lpSystemTime); CString TimedLog; TimedLog.Format(_T("[%s] ", CurSysTime.Format(_T("%Y%m%d %H:%.. 2016. 10. 18.
[MFC] 프로세스를 이미지 이름으로 검색하여 종료를 기다리기 #include PROCESSENTRY32 entry; entry.dwSize = sizeof(PROCESSENTRY32); HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL); DWORD dwCode = 0; if ( TRUE == Process32First(hSnapshot, &entry)) { while (TRUE == Process32Next(hSnapshot, &entry)) { if (0 == _tcscmp(entry.szExeFile, _T("myfile.exe"))) { HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID); dwCo.. 2016. 10. 7.
반응형