{"id":113,"date":"2010-04-17T22:56:24","date_gmt":"2010-04-18T07:56:24","guid":{"rendered":"\/blog\/?p=113"},"modified":"2023-09-21T09:41:14","modified_gmt":"2023-09-21T00:41:14","slug":"%ec%9c%88%eb%8f%84%ec%9a%b0-explorer%ec%9d%98-contextmenu%ec%97%90-%ec%82%ac%ec%9a%a9%ec%9e%90-%eb%a9%94%eb%89%b4%ed%95%ad%eb%aa%a9%ec%9d%84-%ec%b6%94%ea%b0%80%ed%95%98%eb%8a%94-%eb%b0%a9%eb%b2%95","status":"publish","type":"post","link":"https:\/\/hasu0707.duckdns.org\/blog\/?p=113","title":{"rendered":"\uc708\ub3c4\uc6b0 explorer\uc758 contextmenu\uc5d0 \uc0ac\uc6a9\uc790 \uba54\ub274\ud56d\ubaa9\uc744 \ucd94\uac00\ud558\ub294 \ubc29\ubc95"},"content":{"rendered":"\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">\uc708\ub3c4\uc6b0 explorer\uc758 contextmenu\uc5d0 \uc0ac\uc6a9\uc790 \uba54\ub274\ud56d\ubaa9\uc744 \ucd94\uac00\ud558\ub294 \ubc29\ubc95.<\/SPAN><\/P>\n<P><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">1. ATL COM AppWizard\ub97c \uc774\uc6a9 \ud504\ub85c\uc81d\ud2b8\ub97c \uc0dd\uc131\ud55c\ub2e4.<\/SPAN><\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">2. New ATL Object\ub85c Simple Object\ub97c \ucd94\uac00\ud55c\ub2e4.<\/SPAN><\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">3. \ucd94\uac00\ud55c Simple Object\uc758 \ud5e4\ub354 \ud30c\uc77c\uc744 \ubcf4\uba74 \uc544\ub798\uc640 \ube44\uc2b7\ud55c \ud56d\ubaa9\ub4e4\uc774 \uc788\ub294\ub370 \uc801\ub2f9\ud788 \ucd94\uac00\ud55c\ub2e4.<\/SPAN><\/P>\n<P>&nbsp;<\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">#include \"IContextMenuImpl.h\"&nbsp; \/\/\ucd94\uac00\uc120\uc5b8<\/SPAN><\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">class ATL_NO_VTABLE \ud074\ub798\uc2a4 \uc774\ub984:<\/SPAN><\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp;......<\/SPAN><\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp;public IShellExtInit,<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp;public IContextMenuImpl, <\/SPAN><\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp;......<\/SPAN><\/P>\n<P><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">\/\/IContextMenu<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">STDMETHOD(GetCommandString)(UINT, UINT, UINT*, LPTSTR, UINT);<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO);<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">STDMETHOD(QueryContextMenu)(HMENU, UINT, UINT, UINT, UINT);<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">\/\/IShellExtInit<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">STDMETHOD(Initialize)(LPCITEMIDLIST, LPDATAOBJECT, HKEY); <\/SPAN><\/P>\n<P>&nbsp;<\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp;......<\/SPAN><\/P>\n<P>&nbsp;<\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">BEGIN_COM_MAP(CExeMenu)<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp;<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp;......<\/SPAN><\/P>\n<P>&nbsp;<\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">COM_INTERFACE_ENTRY(IShellExtInit)<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">COM_INTERFACE_ENTRY(IContextMenu)<\/SPAN><\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">END_COM_MAP()<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp;&nbsp; <\/SPAN><\/P>\n<P>&nbsp;<\/P>\n<P>&nbsp;<\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">4. \uc774\ubc88\uc5d4 cpp\ud30c\uc77c\uc5d0 \ucd94\uac00\ud560 \ub0b4\uc6a9\uc774\ub2e4.<\/SPAN><\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">\/\/\uc774 shell extension\uc740 contextmenu\uc5d0 list\ub97c \ucd94\uac00\ud558\uae30 \uc704\ud55c \uac83 \uc774\ub2e4.<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">HRESULT \ud074\ub798\uc2a4\uc774\ub984::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idComdFirst, UINT idComdLast, UINT uFlags)<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">{<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; UINT idCmd = idComdFirst;<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp;<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; \/\/context menu insert \uc790\uc138\ud55c \ub0b4\uc6a9\uc740 MSDN\ucc38\uc870.<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; InsertMenu(hmenu, indexMenu, MF_STRING | MF_BYPOSITION, idCmd++, __TEXT(\"\uba54\ub274\uc5d0 \ud45c\uc2dc\ub420 Text\"));<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; m_FileState = TRUE;<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp;<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, idCmd - idComdFirst);<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">}<\/SPAN><\/P>\n<P>&nbsp;<\/P>\n<P>&nbsp;<\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">\/\/Initialize<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">HRESULT \ud074\ub798\uc2a4\uc774\ub984::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY hKeyProgID)<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">{<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; if(lpdobj == NULL)<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return E_INVALIDARG;<\/SPAN><\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; STGMEDIUM medium;<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; \/\/CD_HDROP\ud615\uc73c\ub85c \ub41c \ub370\uc774\ud130\ub97c \uad6c\ud55c\ub2e4.<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; FORMATETC fe = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; HRESULT hr = lpdobj-&gt;GetData(&amp;fe, &amp;medium);<\/SPAN><\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; if(FAILED(hr))<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return E_INVALIDARG;<\/SPAN><\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; \/\/\uc120\ud0dd\ub41c \ud30c\uc77c\uc774\ub984\uc744 \uad6c\ud55c\ub2e4.<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; DragQueryFile(reinterpret_cast&lt;HDROP&gt;(medium.hGlobal), 0, m_szFile, MAX_PATH);<\/SPAN><\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp; &nbsp; &nbsp; ReleaseStgMedium(&amp;medium);<\/SPAN><\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">return hr;<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">}<\/SPAN><\/P>\n<P>&nbsp;<\/P>\n<P>&nbsp;<\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">\/\/contextmenu\uc5d0 \ucd94\uac00\ud55c \ud56d\ubaa9\uc5d0 \uad00\ud55c \uc0c1\ud0dc\ubc14\uc5d0 \uc124\uba85\uc744 \ud45c\uc2dc\ud558\ub294 \ubd80\ubd84\uc774\ub2e4.<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">HRESULT CExeMenu::GetCommandString (UINT idCmd, UINT uFlags, UINT* pwReserved, LPSTR pszName, UINT cchMax)<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">{<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">\/\/ If Explorer is asking for a help string, copy our string into the<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">\/\/ supplied buffer.<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">if ( uFlags &amp; GCS_HELPTEXT )<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">lstrcpyn(pszText, _T(\"This is the simple shell extension's help\"), ccgMax);<\/SPAN><\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">return S_OK;<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">}<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp;<\/SPAN><br \/><\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">&nbsp;\/\/menu\uac00 \uc120\ud0dd\ub418\uc5c8\uc744\uc2dc \uc791\uc5c5\ud558\ub294 \uc601\uc5ed\uc774\ub2e4.<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">HRESULT CExeMenu::InvokeCommand ( LPCMINVOKECOMMANDINFO pCmdInfo )<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">{<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">\/\/ If lpVerb really points to a string, ignore this function call and bail out.<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">if ( 0 != HIWORD( pCmdInfo-&gt;lpVerb ))<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">return E_INVALIDARG;<\/SPAN><\/P>\n<P>&nbsp;<\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">....\ucc98\ub9ac\ud560 \ub0b4\uc6a9 ....<\/SPAN><\/P>\n<P>&nbsp;<\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">\/\/ ex) dlg.DoModal() \uc744 \ud558\uc5ec \ub2e4\uc774\uc5bc\ub85c\uadf8\ub97c \uc0dd\uc131 \uc774\ud6c4 \uc791\uc5c5\uc740 \ub2e4\uc774\uc5bc\ub85c\uadf8\uc5d0\uc11c \ucc98\ub9ac\uac00 \uac00\ub2a5\ud558\ub2e4.<\/SPAN><\/P>\n<P>&nbsp;<\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">return S_OK;<\/SPAN><br \/><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">}<\/SPAN><\/P>\n<P>&nbsp;<\/P>\n<P>&nbsp;<\/P>\n<P><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">\ucc38\uace0&gt;codeproject.com\uc758 \uc608\uc81c \ud504\ub85c\uadf8\ub7a8\uc774\ub2e4. \ucc38\uace0\ud558\uc5ec \uac19\uc774\ubcf4\uc790~~ ^,.^<\/SPAN><\/P>\n<P><a class=\"con_link\" href=\"http:\/\/www.codeproject.com\/shell\/shellextguide2.asp\" target=\"_blank\" _cssquery_UID=\"72\" rel=\"noopener\"><SPAN style=\"FONT-FAMILY: \uad74\ub9bc\uccb4\">http:\/\/www.codeproject.com\/shell\/shellextguide2.asp<\/SPAN><\/A><\/P>\n","protected":false},"excerpt":{"rendered":"<p>\uc708\ub3c4\uc6b0 explorer\uc758 contextmenu\uc5d0 \uc0ac\uc6a9\uc790 \uba54\ub274\ud56d\ubaa9\uc744 \ucd94\uac00\ud558\ub294 \ubc29\ubc95. 1. ATL COM AppWizard\ub97c \uc774\uc6a9 \ud504\ub85c\uc81d\ud2b8\ub97c \uc0dd\uc131\ud55c\ub2e4. 2. New ATL Object\ub85c Simple Object\ub97c \ucd94\uac00\ud55c\ub2e4. 3. \ucd94\uac00\ud55c Simple Object\uc758 \ud5e4\ub354 \ud30c\uc77c\uc744 \ubcf4\uba74 \uc544\ub798\uc640 \ube44\uc2b7\ud55c \ud56d\ubaa9\ub4e4\uc774 \uc788\ub294\ub370 \uc801\ub2f9\ud788 \ucd94\uac00\ud55c\ub2e4. &nbsp; #include &#8220;IContextMenuImpl.h&#8221;&nbsp; \/\/\ucd94\uac00\uc120\uc5b8 class ATL_NO_VTABLE \ud074\ub798\uc2a4 \uc774\ub984: &nbsp;&#8230;&#8230; &nbsp;public IShellExtInit,&nbsp;public IContextMenuImpl, &nbsp;&#8230;&#8230; \/\/IContextMenuSTDMETHOD(GetCommandString)(UINT, UINT, UINT*, LPTSTR, UINT);STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO);STDMETHOD(QueryContextMenu)(HMENU, UINT, UINT, UINT, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[18],"tags":[],"class_list":["post-113","post","type-post","status-publish","format-standard","hentry","category-development_language"],"_links":{"self":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/113","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=113"}],"version-history":[{"count":0,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/113\/revisions"}],"wp:attachment":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}