본문 바로가기

Programming

atlcom.h에서 ClassesAllowedInStream rgclsidAllowed; 에러가 나는 경우 1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlcom.h(431) : error C2146: syntax error : missing ';' before identifier 'rgclsidAllowed' 1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlcom.h(431) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlcom.. 더보기
서브폴더 생성하기 typedef std::basic_string tstring; bool CreateSubDirectory(LPCTSTR folder) { ATLASSERT(folder); if(!folder) { SetLastError(ERROR_INVALID_PARAMETER); return false; } tstring strFoler(folder); if(strFoler.empty() || strFoler.find(_T("\\")) == tstring::npos) { return false; } size_t pos(0); tstring temp; if(strFoler[strFoler.size()-1] != _T('\\')) { strFoler.append(_T("\\")); } bool ret(true); whil.. 더보기
풀패스에서 폴더명, 파일명 얻어 오는 함수 typedef std::basic_string tstring; tstring ExtractStringWithDelim(LPCTSTR dump, const TCHAR delim, bool isLast) { if(!dump) { return _T(""); } tstring ret(dump); size_t pos = ret.rfind(delim); if(pos != tstring::npos) { if(isLast) { ret = ret.substr(pos+1, ret.length()); } else { ret = ret.substr(0, pos); } } return ret; } tstring ExtractPathFromUrl(LPCTSTR path) { return ExtractStringWithDelim(.. 더보기
파일 코드사인(디지털서명) 여부 확인 //------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Example of verifying the embedded signature of a PE file by using // the WinVerifyTrust function. #include #include #include #include #include #include #include // Link with the Wintrust.lib file. #pragma comment (lib, "wintrust") bool VerifyEmbeddedSignature(LPCT.. 더보기
ASP.Net 에러 - 서버 응용 프로그램을 사용할 수 없습니다. 서버 응용 프로그램을 사용할 수 없습니다. 이 웹 서버에서 액세스 하려는 웹 응용 프로그램을 현재 사용할 수 없습니다. 웹 브라우저의 [새로고침] 단추를 눌러 다시 요청하십시오....생략 해당 에러가 뜰 경우 Command 에서 aspnet_regiis -i로 aspnet을 새로 설치해 주어야 한다. 더보기
유니코드 빌드시 툴팁 윈도우 생성되지 않는 버그 Unicode에서 win32로 구현할 경우 생성되지 않는 문제 typedef struct tagTOOLINFOW { UINT cbSize; UINT uFlags; HWND hwnd; UINT_PTR uId; RECT rect; HINSTANCE hinst; LPWSTR lpszText; #if (_WIN32_IE >= 0x0300) LPARAM lParam; #endif #if (_WIN32_WINNT >= 0x0501) void *lpReserved; #endif } TTTOOLINFOW, NEAR *PTOOLINFOW, *LPTTTOOLINFOW; 구조체에서 WIN32_WINNT가 기본값이 0x0501로 설정되어 있음 VS버그로 추정되나 Stdafx.h의 WIN32_WINNT값을 수정하여 컴파일시 동.. 더보기
IsUtf8 문자열이 Utf8인지 체크하는 함수 전체 문자열을 검사하여 한 문자열이라도 utf8 코드가 들어 있는 경우 true를 리턴 bool IsUtf8(const char* str) { int str_bytes = 0; if(str == NULL ) { return false; } str_bytes = strlen(str); bool isUtf8(true); int index = 0; while (index < str_bytes && isUtf8) { char achar = str[index]; int supplemental_bytes = 0; if ((achar & 0x80) == 0) { // 0xxxxxxx ++index; } else if ((achar & 0xF8) == 0xF0) { // 11110uuu 10uuzzzz 10yyyyyy.. 더보기
대문자 변환, 소문자 변환 문자열을 대문자로 또는 소문자로 변환하기 위한 함수 이렇게 두개의 함수를 만들어 두면 TCHAR 로 컴파일 해도 별 문제없이 사용할 수 있고 각각 char, wchar_t로 사용시에도 편리하게 사용할 수 있다. std::string MakeLower(LPCSTR src) { std::string temp(src); std::transform(temp.begin(), temp.end(), temp.begin(), _mbctolower); return temp; } std::wstring MakeLower(LPCWSTR src) { std::wstring temp(src); std::transform(temp.begin(), temp.end(), temp.begin(), towlower); return te.. 더보기