Skip to content

Commit 3ee72aa

Browse files
committed
3.6.0.0
1 parent d68e80b commit 3ee72aa

12 files changed

Lines changed: 84 additions & 61 deletions

File tree

License.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
MIT License
3+
4+
Copyright (C) 2008-2020 Frank Skare (stax76)
5+
6+
Permission is hereby granted, free of charge, to any person
7+
obtaining a copy of this software and ssociated documentation
8+
files (the "Software"), to deal in the Software without restriction,
9+
including without limitation the rights to use, copy, modify, merge,
10+
publish, distribute, sublicense, and/or sell copies of the Software,
11+
and to permit persons to whom the Software is furnished to do so,
12+
subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be
15+
included in all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
24+
THE USE OR OTHER DEALINGS IN THE SOFTWARE.

OpenWithPP.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Global
1515
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1616
{352818B6-523C-4143-9BB6-9C263E73D0A6}.Debug|x64.ActiveCfg = Debug|x64
1717
{352818B6-523C-4143-9BB6-9C263E73D0A6}.Debug|x64.Build.0 = Debug|x64
18-
{352818B6-523C-4143-9BB6-9C263E73D0A6}.Release|x64.ActiveCfg = Release|x64
19-
{352818B6-523C-4143-9BB6-9C263E73D0A6}.Release|x64.Build.0 = Release|x64
18+
{352818B6-523C-4143-9BB6-9C263E73D0A6}.Release|x64.ActiveCfg = Debug|x64
19+
{352818B6-523C-4143-9BB6-9C263E73D0A6}.Release|x64.Build.0 = Debug|x64
2020
{D66A39BE-CA8D-4A68-AD8E-10DE640332BA}.Debug|x64.ActiveCfg = Debug|x64
2121
{D66A39BE-CA8D-4A68-AD8E-10DE640332BA}.Debug|x64.Build.0 = Debug|x64
2222
{D66A39BE-CA8D-4A68-AD8E-10DE640332BA}.Release|x64.ActiveCfg = Release|x64

OpenWithPPGUI/MainForm.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ Public Class MainForm
10671067

10681068
Using proc As New Process
10691069
proc.StartInfo.Verb = "runas"
1070-
proc.StartInfo.FileName = "regsvr32"
1070+
proc.StartInfo.FileName = "regsvr32.exe"
10711071
proc.StartInfo.Arguments = "/u """ + DLLPath + """"
10721072
proc.Start()
10731073
End Using

OpenWithPPGUI/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ Imports System.Runtime.InteropServices
2929
' You can specify all the values or you can default the Build and Revision Numbers
3030
' by using the '*' as shown below:
3131

32-
<Assembly: AssemblyVersion("3.5.0.0")>
33-
<Assembly: AssemblyFileVersion("3.5.0.0")>
32+
<Assembly: AssemblyVersion("3.6.0.0")>
33+
<Assembly: AssemblyFileVersion("3.6.0.0")>

OpenWithPPShellExtension/Common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
#pragma once
3+
4+
#define PRODUCT_NAME L"OpenWithPP"

OpenWithPPShellExtension/DLL.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11

22
#include "stdafx.h"
3+
#include "Common.h"
34
#include "Util.h"
45

56

67
HMODULE g_hmodThis;
78

89

9-
class COpenWithPPShellExtensionModule : public CAtlDllModuleT< COpenWithPPShellExtensionModule >
10+
class COpenWithPPShellExtensionModule : public ATL::CAtlDllModuleT< COpenWithPPShellExtensionModule >
1011
{
1112
public :
1213
};

OpenWithPPShellExtension/DLL.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
; OpenWithPPShellExtension.def : Declares the module parameters.
23

34
LIBRARY "OpenWithPPShellExtension.dll"

OpenWithPPShellExtension/Main.cpp

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11

22
#include "stdafx.h"
33
#include "Main.h"
4-
#include "Util.h"
5-
#include "atlstr.h"
6-
#include "wincodec.h"
74

85

96
Item::~Item()
@@ -22,7 +19,7 @@ BOOL FileExist(std::wstring file)
2219
return false;
2320

2421
DWORD dwAttrib = GetFileAttributes(file.c_str());
25-
return (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
22+
return dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY);
2623
}
2724

2825

@@ -87,16 +84,15 @@ HBITMAP ConvertIconToBitmap(HICON hicon)
8784
}
8885

8986

90-
HRESULT SetIcon(HMENU menu, UINT command, Item* item)
87+
HRESULT SetIcon(HMENU menu, UINT position, UINT flags, Item* item)
9188
{
9289
if (!FileExist(item->IconFile))
9390
return S_OK;
9491

9592
if (!item->Icon)
9693
{
9794
HICON iconSmall;
98-
HICON iconLarge = NULL;
99-
int res = ExtractIconEx(item->IconFile.c_str(), item->IconIndex, &iconLarge, &iconSmall, 1);
95+
int res = ExtractIconEx(item->IconFile.c_str(), item->IconIndex, NULL, &iconSmall, 1);
10096

10197
if (!res)
10298
return E_FAIL;
@@ -106,16 +102,13 @@ HRESULT SetIcon(HMENU menu, UINT command, Item* item)
106102
if (iconSmall)
107103
DestroyIcon(iconSmall);
108104

109-
if (iconLarge)
110-
DestroyIcon(iconLarge);
111-
112105
if (!bmp)
113106
return E_FAIL;
114107

115108
item->Icon = bmp;
116109
}
117110

118-
int res = SetMenuItemBitmaps(menu, command, MF_BYCOMMAND, item->Icon, item->Icon);
111+
int res = SetMenuItemBitmaps(menu, position, flags, item->Icon, item->Icon);
119112

120113
if (!res)
121114
return E_FAIL;
@@ -172,62 +165,61 @@ HRESULT CMain::LoadXML()
172165

173166
g_Items.clear();
174167

175-
TCHAR path[MAX_PATH];
176-
SHRegGetPath(HKEY_CURRENT_USER, L"Software\\" PRODUCT_NAME,
177-
L"SettingsLocation", path, NULL);
168+
WCHAR path[MAX_PATH];
169+
SHRegGetPath(HKEY_CURRENT_USER, L"Software\\" PRODUCT_NAME, L"SettingsLocation", path, NULL);
178170

179171
if (!FileExist(path))
180172
return E_FAIL;
181173

182-
CComPtr<IXMLDOMDocument> doc;
174+
ATL::CComPtr<IXMLDOMDocument> doc;
183175
HRESULT hr = doc.CoCreateInstance(__uuidof(DOMDocument));
184176

185177
if (FAILED(hr))
186178
return hr;
187179

188180
VARIANT_BOOL success;
189-
hr = doc->load(CComVariant(path), &success);
181+
hr = doc->load(ATL::CComVariant(path), &success);
190182

191183
if (FAILED(hr))
192184
return hr;
193185

194-
CComPtr<IXMLDOMNodeList> items;
195-
hr = doc->selectNodes(CComBSTR(L"AppSettings/Items/Item"), &items);
186+
ATL::CComPtr<IXMLDOMNodeList> items;
187+
hr = doc->selectNodes(ATL::CComBSTR(L"AppSettings/Items/Item"), &items);
196188

197189
if (FAILED(hr))
198190
return hr;
199191

200-
IXMLDOMNode *itemNode;
192+
IXMLDOMNode* itemNode;
201193

202-
while (!items->nextNode(&itemNode))
194+
while (S_OK == items->nextNode(&itemNode))
203195
{
204196
Item* item = new Item();
205197

206-
CComPtr<IXMLDOMNodeList> itemFields;
198+
ATL::CComPtr<IXMLDOMNodeList> itemFields;
207199
hr = itemNode->get_childNodes(&itemFields);
208200

209201
if FAILED(hr)
210202
hr;
211203

212-
IXMLDOMNode *itemField;
204+
IXMLDOMNode* itemField;
213205

214-
while (!itemFields->nextNode(&itemField))
206+
while (S_OK == itemFields->nextNode(&itemField))
215207
{
216208
BSTR nodeName;
217209
hr = itemField->get_nodeName(&nodeName);
218210

219211
if FAILED(hr)
220212
return hr;
221213

222-
CComBSTR cNodeName(nodeName);
214+
ATL::CComBSTR cNodeName(nodeName);
223215

224216
BSTR nodeText;
225217
hr = itemField->get_text(&nodeText);
226218

227219
if FAILED(hr)
228220
return hr;
229221

230-
CComBSTR cNodeText(nodeText);
222+
ATL::CComBSTR cNodeText(nodeText);
231223

232224
if (cNodeName == L"Name")
233225
item->Name = cNodeText;
@@ -280,29 +272,29 @@ STDMETHODIMP CMain::Initialize(
280272

281273
int uNumFiles = DragQueryFile((HDROP)stg.hGlobal, 0xFFFFFFFF, NULL, 0);
282274

283-
if (0 == uNumFiles)
275+
if (!uNumFiles)
284276
{
285277
ReleaseStgMedium(&stg);
286278
return E_INVALIDARG;
287279
}
288280

289281
for (int i = 0; i < uNumFiles; i++)
290282
{
291-
TCHAR buf[MAX_PATH];
292-
DragQueryFile((HDROP)stg.hGlobal, i, buf, MAX_PATH);
293-
g_ShellItems.push_back(buf);
283+
WCHAR buffer[MAX_PATH];
284+
DragQueryFile((HDROP)stg.hGlobal, i, buffer, MAX_PATH);
285+
g_ShellItems.push_back(buffer);
294286
}
295287

296288
ReleaseStgMedium(&stg);
297289
}
298290
else if (pidlFolder)
299291
{
300-
TCHAR buf[MAX_PATH];
292+
WCHAR buffer[MAX_PATH];
301293

302-
if (!SHGetPathFromIDList(pidlFolder, buf))
294+
if (!SHGetPathFromIDList(pidlFolder, buffer))
303295
return E_FAIL;
304296

305-
g_ShellItems.push_back(buf);
297+
g_ShellItems.push_back(buffer);
306298
}
307299
else
308300
return E_FAIL;
@@ -314,12 +306,11 @@ STDMETHODIMP CMain::Initialize(
314306
STDMETHODIMP CMain::QueryContextMenu(
315307
HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd, UINT uidLastCmd, UINT uFlags)
316308
{
317-
if (g_Items.size() == 0 || SHRegGetBoolUSValue(
309+
if (!g_Items.size() || SHRegGetBoolUSValue(
318310
L"Software\\" PRODUCT_NAME, L"Reload", FALSE, TRUE))
319311
{
320312
REGISTRY_ENTRY re = GetRegEntry(HKEY_CURRENT_USER,
321-
L"Software\\" PRODUCT_NAME, L"Reload",
322-
NULL, REG_DWORD, 0);
313+
L"Software\\" PRODUCT_NAME, L"Reload", NULL, REG_DWORD, 0);
323314

324315
if (FAILED(CreateRegKeyAndSetValue(&re)))
325316
return E_FAIL;
@@ -366,7 +357,7 @@ STDMETHODIMP CMain::QueryContextMenu(
366357
if (!res)
367358
return E_FAIL;
368359

369-
SetIcon(hmenu, command, g_Items[i]);
360+
SetIcon(hmenu, command, MF_BYCOMMAND, g_Items[i]);
370361
addSubSep = true;
371362
}
372363
else
@@ -376,7 +367,7 @@ STDMETHODIMP CMain::QueryContextMenu(
376367
if (!res)
377368
return E_FAIL;
378369

379-
SetIcon(hmenu, command, g_Items[i]);
370+
SetIcon(hmenu, uMenuIndex, MF_BYPOSITION, g_Items[i]);
380371
uMenuIndex += 1;
381372
}
382373

@@ -408,7 +399,7 @@ STDMETHODIMP CMain::QueryContextMenu(
408399
if (!res)
409400
return E_FAIL;
410401

411-
SetIcon(hmenu, command, g_Items[i]);
402+
SetIcon(hmenu, command, MF_BYCOMMAND, g_Items[i]);
412403
addSubSep2 = true;
413404
}
414405
else
@@ -418,7 +409,7 @@ STDMETHODIMP CMain::QueryContextMenu(
418409
if (!res)
419410
return E_FAIL;
420411

421-
SetIcon(hmenu, command, g_Items[i]);
412+
SetIcon(hmenu, uMenuIndex, MF_BYPOSITION, g_Items[i]);
422413
uMenuIndex += 1;
423414
}
424415

@@ -470,15 +461,15 @@ STDMETHODIMP CMain::InvokeCommand(LPCMINVOKECOMMANDINFO pCmdInfo)
470461
if (args.find(L"%items%") != std::wstring::npos)
471462
{
472463
std::wstring joined = L"\"" + JoinList(&g_ShellItems, L"\" \"") + L"\"";
473-
CString argh = args.c_str();
464+
ATL::CString argh = args.c_str();
474465
argh.Replace(L"%items%", joined.c_str());
475466
args = argh.GetBuffer();
476467
}
477468

478469
if (args.find(L"%paths%") != std::wstring::npos)
479470
{
480471
std::wstring joined = L"\"" + JoinList(&g_ShellItems, L"\" \"") + L"\"";
481-
CString argh = args.c_str();
472+
ATL::CString argh = args.c_str();
482473
argh.Replace(L"%paths%", joined.c_str());
483474
args = argh.GetBuffer();
484475
}

OpenWithPPShellExtension/Main.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11

22
#pragma once
33

4-
#include <initguid.h>
4+
#include "Util.h"
5+
#include "Common.h"
56

6-
#include <list>
7-
#include <vector>
8-
#include <algorithm>
9-
#include <string>
107

118
EXTERN_C const CLSID CLSID_Main;
129

@@ -45,8 +42,8 @@ int g_EditCommandIndex;
4542
// CMain
4643

4744
class ATL_NO_VTABLE CMain :
48-
public CComObjectRootEx<CComSingleThreadModel>,
49-
public CComCoClass<CMain, &CLSID_Main>,
45+
public ATL::CComObjectRootEx<ATL::CComSingleThreadModel>,
46+
public ATL::CComCoClass<CMain, &CLSID_Main>,
5047
public IShellExtInit,
5148
public IContextMenu
5249
{

OpenWithPPShellExtension/OpenWithPPShellExtension.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
<None Include="DLL.def" />
143143
</ItemGroup>
144144
<ItemGroup>
145+
<ClInclude Include="Common.h" />
145146
<ClInclude Include="Main.h" />
146147
<ClInclude Include="stdafx.h" />
147148
<ClInclude Include="Util.h" />

0 commit comments

Comments
 (0)