10월, 2018의 게시물 표시

static_cast와 reinterpret_cast 예제로 본 차이

#include "stdafx.h" #include <stdio.h> class shape{ private:     int a; public:     virtual void draw() { printf("share::draw() \n"); } }; class rect : public shape { private:     int b; public:     rect() { b = 30; }     void draw() { printf("rect::draw() \n"); }     void onlyRect() { printf("rect::onlyRect() \n"); } }; int _tmain(int argc, _TCHAR* argv[]) {     int arData[] = {1,2,3,4};     int * ptr = static_cast<int *>(arData);     char * pStr = "ABC";     ptr = static_cast<int *>(pStr); // error C2440: 'static_cast' : 'char *'에서 'int *'(으)로 변환할 수 없습니다.     rect rcTest;     shape * pShare = static_cast<shape *>(&rcTest);        // upcast     pShare->draw();     shape parent;     rect * pRect =...

ShellExecuteEx 예제

displayname 아닌 parsingname 얻어와서 호출하는 예제(IShellFolder 통해서 원하는 파일 찾는 부분 참고) https://docs.microsoft.com/ko-kr/windows/desktop/shell/launch #include <shlobj.h> #include <shlwapi.h> #include <objbase.h> main() {     LPITEMIDLIST pidlWinFiles = NULL;     LPITEMIDLIST pidlItems = NULL;     IShellFolder *psfWinFiles = NULL;     IShellFolder *psfDeskTop = NULL;     LPENUMIDLIST ppenum = NULL;     STRRET strDispName;     TCHAR pszParseName[MAX_PATH];     ULONG celtFetched;     SHELLEXECUTEINFO ShExecInfo;     HRESULT hr;     BOOL fBitmap = FALSE;     hr = SHGetFolderLocation(NULL, CSIDL_WINDOWS, NULL, NULL, &pidlWinFiles);     hr = SHGetDesktopFolder(&psfDeskTop);     hr = psfDeskTop->BindToObject(pidlWinFiles, NULL, IID_IShellFolder, (L...