| 129 | wParam, lParam ); |
| 130 | } |
| 131 | BOOL GetContextMenu ( LPCWSTR path, void **ppContextMenu, int &iMenuType ) |
| 132 | { |
| 133 | *ppContextMenu = NULL; |
| 134 | LPCONTEXTMENU icm1 = NULL; |
| 135 | // first we retrieve the normal IContextMenu |
| 136 | // interface (every object should have it) |
| 137 | LPCITEMIDLIST idChild = 0; |
| 138 | IShellFolder *ifolder = 0; |
| 139 | ITEMIDLIST *id = 0; |
| 140 | std::wstring windowsPath = path; |
| 141 | std::replace ( windowsPath.begin(), windowsPath.end(), '/', '\\' ); |
| 142 | HRESULT result = SHParseDisplayName ( windowsPath.c_str(), 0, &id, 0, 0 ); |
| 143 | if ( !SUCCEEDED ( result ) || !id ) { |
| 144 | return false; |
| 145 | } |
| 146 | result = SHBindToParent ( id, IID_IShellFolder, ( void ** ) &ifolder, &idChild ); |
| 147 | ifolder->GetUIObjectOf ( NULL, |
| 148 | 1, |
| 149 | ( LPCITEMIDLIST * ) &idChild, |
| 150 | IID_IContextMenu, |
| 151 | NULL, |
| 152 | ( void ** ) &icm1 ); |
| 153 | if ( icm1 ) { |
| 154 | // since we got an IContextMenu interface we can |
| 155 | // now obtain the higher version interfaces via that |
| 156 | if ( icm1->QueryInterface ( IID_IContextMenu3, ppContextMenu ) == NOERROR ) { |
| 157 | iMenuType = 3; |
| 158 | } else if ( icm1->QueryInterface ( IID_IContextMenu2, |
| 159 | ppContextMenu ) == NOERROR ) { |
| 160 | iMenuType = 2; |
| 161 | } |
| 162 | if ( *ppContextMenu ) { |
| 163 | icm1->Release(); // we can now release version 1 interface, |
| 164 | } |
| 165 | // cause we got a higher one |
| 166 | else { |
| 167 | iMenuType = 1; |
| 168 | *ppContextMenu = icm1; // since no higher versions were found |
| 169 | } // redirect ppContextMenu to version 1 interface |
| 170 | } else { |
| 171 | return ( FALSE ); // something went wrong |
| 172 | } |
| 173 | return ( TRUE ); // success |
| 174 | } |
| 175 | |
| 176 | //UINT ShowContextMenu(CWnd *pWnd, CPoint pt) |
| 177 | BOOL HL_Explorer_cxt_menu ( LPCWSTR path, void *parentWindow ) |
no test coverage detected