MCPcopy Create free account
hub / github.com/TortoiseGit/TortoiseGit / Initialize

Method Initialize

src/TortoiseShell/ContextMenu.cpp:52–352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50static int g_syncSeq = 0;
51
52STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY /* hRegKey */)
53{
54 CTraceToOutputDebugString::Instance()(__FUNCTION__ ": Shell :: Initialize\n");
55 PreserveChdir preserveChdir;
56 files_.clear();
57 folder_.clear();
58 uuidSource.clear();
59 uuidTarget.clear();
60 itemStates = 0;
61 itemStatesFolder = 0;
62 std::wstring statuspath;
63 git_wc_status_kind fetchedstatus = git_wc_status_none;
64 // get selected files/folders
65 if (pDataObj)
66 {
67 STGMEDIUM medium;
68 FORMATETC fmte = { static_cast<CLIPFORMAT>(g_shellidlist),
69 nullptr,
70 DVASPECT_CONTENT,
71 -1,
72 TYMED_HGLOBAL};
73 HRESULT hres = pDataObj->GetData(&fmte, &medium);
74
75 if (SUCCEEDED(hres) && medium.hGlobal)
76 {
77 SCOPE_EXIT
78 {
79 ReleaseStgMedium(&medium);
80 if (medium.pUnkForRelease)
81 {
82 IUnknown* relInterface = medium.pUnkForRelease;
83 relInterface->Release();
84 }
85 };
86 if (m_State == FileStateDropHandler)
87 {
88 if (!CRegStdDWORD(L"Software\\TortoiseGit\\EnableDragContextMenu", TRUE, false, HKEY_CURRENT_USER, KEY_WOW64_64KEY))
89 return S_OK;
90
91 FORMATETC etc = { CF_HDROP, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
92 STGMEDIUM stg = { TYMED_HGLOBAL };
93 if ( FAILED( pDataObj->GetData ( &etc, &stg )))
94 return E_INVALIDARG;
95 SCOPE_EXIT { ReleaseStgMedium(&stg); };
96
97 auto drop = static_cast<HDROP>(GlobalLock(stg.hGlobal));
98 if (!drop)
99 return E_INVALIDARG;
100 SCOPE_EXIT { GlobalUnlock(drop); };
101
102 const int count = DragQueryFile(drop, UINT(-1), nullptr, 0);
103 if (count == 1)
104 itemStates |= ITEMIS_ONLYONE;
105 for (int i = 0; i < count; i++)
106 {
107 // find the path length in chars
108 const UINT len = DragQueryFile(drop, i, nullptr, 0);
109 if (len == 0 || len >= INT_MAX)

Callers

nothing calls this directly

Calls 15

IsContextPathAllowedMethod · 0.80
SetFromWinMethod · 0.80
GetFileExtensionMethod · 0.80
GetCacheTypeMethod · 0.80
IsAdminDirMethod · 0.80
GetAdminDirMaskMethod · 0.80
toStringMethod · 0.80
IsSimpleContextMethod · 0.80
HasGITAdminDirMethod · 0.80
clearMethod · 0.45
GetDataMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected