ReactOS  0.4.14-dev-384-g5b37caa
CVfdShExt Class Reference

#include <vfdshext.h>

Inheritance diagram for CVfdShExt:
Collaboration diagram for CVfdShExt:

Public Member Functions

 CVfdShExt ()
 
 ~CVfdShExt ()
 
DWORD DoVfdOpen (HWND hParent)
 
DWORD DoVfdNew (HWND hParent)
 
DWORD DoVfdClose (HWND hParent)
 
DWORD DoVfdSave (HWND hParent)
 
DWORD DoVfdProtect (HWND hParent)
 
DWORD DoVfdDrop (HWND hParent)
 
ULONG GetDevice ()
 
PCSTR GetTarget ()
 
STDMETHODIMP QueryInterface (REFIID, LPVOID *)
 
 STDMETHODIMP_ (ULONG) AddRef()
 
 STDMETHODIMP_ (ULONG) Release()
 
STDMETHODIMP Initialize (LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hKeyID)
 
STDMETHODIMP QueryContextMenu (HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
 
STDMETHODIMP InvokeCommand (LPCMINVOKECOMMANDINFO lpcmi)
 
STDMETHODIMP GetCommandString (UINT idCmd, UINT uFlags, UINT *reserved, LPSTR pszName, UINT cchMax)
 
STDMETHODIMP AddPages (LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
 
STDMETHODIMP ReplacePage (UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam)
 
- Public Member Functions inherited from IContextMenu
HRESULT GetCommandString ([in] UINT_PTR idCmd, [in] UINT uType, [out] UINT *pwReserved, [out, size_is(cchMax)] LPSTR pszName, [in] UINT cchMax)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Protected Attributes

ULONG m_cRefCnt
 
LPDATAOBJECT m_pDataObj
 
ULONG m_nDevice
 
CHAR m_sTarget [MAX_PATH]
 
BOOL m_bDragDrop
 

Additional Inherited Members

- Public Types inherited from IContextMenu
typedef struct IContextMenu::tagCMINVOKECOMMANDINFO CMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMINVOKECOMMANDINFOLPCMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMInvokeCommandInfoEx CMINVOKECOMMANDINFOEX
 
typedef struct IContextMenu::tagCMInvokeCommandInfoExLPCMINVOKECOMMANDINFOEX
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Attributes inherited from IContextMenu
CMIC_MASK_NOZONECHECKS typedef IContextMenuLPCONTEXTMENU
 
- Static Public Attributes inherited from IContextMenu
static CMDSTR_VIEWDETAILSW(const WCHAR []) const WCHAR CMDSTR_NEWFOLDERW [] = {'N','e','w','F','o','l','d','e','r',0}
 
static const WCHAR CMDSTR_VIEWLISTW [] = {'V','i','e','w','L','i','s','t',0}
 
static const WCHAR CMDSTR_VIEWDETAILSW [] = {'V','i','e','w','D','e','t','a','i','l','s',0}
 
- Private Types inherited from IShellExtInit
typedef IShellExtInitLPSHELLEXTINIT
 
- Private Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Private Types inherited from IShellPropSheetExt
enum  tagSHELLPROPSHEETEXTPAGEID { EXPPS_FILETYPES = 0x1 }
 
typedef UINT EXPPS
 
- Private Member Functions inherited from IShellExtInit
HRESULT Initialize ([in] PCIDLIST_ABSOLUTE pidlFolder, [in] IDataObject *pdtobj, [in] HKEY hkeyProgID)
 
- Private Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 
- Private Member Functions inherited from IShellPropSheetExt
HRESULT AddPages ([in] LPFNSVADDPROPSHEETPAGE pfnAddPage, [in] LPARAM lParam)
 
HRESULT ReplacePage ([in] EXPPS uPageID, [in] LPFNSVADDPROPSHEETPAGE pfnReplaceWith, [in] LPARAM lParam)
 

Detailed Description

Definition at line 18 of file vfdshext.h.

Constructor & Destructor Documentation

◆ CVfdShExt()

CVfdShExt::CVfdShExt ( )

Definition at line 26 of file vfdshext.cpp.

27 {
28  VFDTRACE(0, ("CVfdShExt::CVfdShExt()\n"));
29 
30  m_cRefCnt = 0L;
31  m_pDataObj = NULL;
32  m_nDevice = (ULONG)-1;
33  m_sTarget[0] = '\0';
35 
36  g_cDllRefCnt++;
37 }
UINT g_cDllRefCnt
LPDATAOBJECT m_pDataObj
Definition: vfdshext.h:25
BOOL m_bDragDrop
Definition: vfdshext.h:28
ULONG m_nDevice
Definition: vfdshext.h:26
smooth NULL
Definition: ftsmooth.c:416
CHAR m_sTarget[MAX_PATH]
Definition: vfdshext.h:27
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
static const WCHAR L[]
Definition: oid.c:1250
ULONG m_cRefCnt
Definition: vfdshext.h:24
unsigned int ULONG
Definition: retypes.h:1

◆ ~CVfdShExt()

CVfdShExt::~CVfdShExt ( )

Definition at line 42 of file vfdshext.cpp.

43 {
44  VFDTRACE(0, ("CVfdShExt::~CVfdShExt()\n"));
45 
46  if (m_pDataObj) {
47  m_pDataObj->Release();
48  }
49 
50  g_cDllRefCnt--;
51 }
UINT g_cDllRefCnt
LPDATAOBJECT m_pDataObj
Definition: vfdshext.h:25
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72

Member Function Documentation

◆ AddPages()

STDMETHODIMP CVfdShExt::AddPages ( LPFNADDPROPSHEETPAGE  lpfnAddPage,
LPARAM  lParam 
)

Definition at line 416 of file vfdshprop.cpp.

419 {
420  PROPSHEETPAGE psp;
421  HPROPSHEETPAGE hpage;
422 
423  if (!m_pDataObj || m_nDevice == (ULONG)-1) {
424  // not a VFD drive
425  VFDTRACE(0, ("PropPage: Not a VFD drive\n"));
426 
427  return NOERROR;
428  }
429 
430  psp.dwSize = sizeof(psp); // no extra data.
432  psp.hInstance = g_hDllModule;
433  psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPDIALOG);
434  psp.hIcon = 0;
435  psp.pszTitle = "VFD";
436  psp.pfnDlgProc = VfdPageDlgProc;
437  psp.pcRefParent = &g_cDllRefCnt;
438  psp.pfnCallback = VfdPageCallback;
439  psp.lParam = (LPARAM)this;
440 
441  AddRef();
442  hpage = CreatePropertySheetPage(&psp);
443 
444  if (hpage) {
445  if (!lpfnAddPage(hpage, lParam)) {
447  Release();
448  }
449  }
450 
451  return NOERROR;
452 }
#define IDD_PROPDIALOG
Definition: vfdguirc.h:5
#define MAKEINTRESOURCE
Definition: winuser.h:591
UINT g_cDllRefCnt
#define NOERROR
Definition: winerror.h:2354
BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage)
Definition: propsheet.c:3144
LPDATAOBJECT m_pDataObj
Definition: vfdshext.h:25
#define PSP_USECALLBACK
Definition: prsht.h:30
static BOOL CALLBACK VfdPageDlgProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
Definition: vfdshprop.cpp:84
ULONG m_nDevice
Definition: vfdshext.h:26
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
ULONG Release()
LONG_PTR LPARAM
Definition: windef.h:208
#define CreatePropertySheetPage
Definition: prsht.h:381
HINSTANCE g_hDllModule
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
ULONG AddRef()
#define PSP_USEREFPARENT
Definition: prsht.h:29
#define PSP_USETITLE
Definition: prsht.h:26
unsigned int ULONG
Definition: retypes.h:1
static UINT CALLBACK VfdPageCallback(HWND hWnd, UINT uMessage, LPPROPSHEETPAGE ppsp)
Definition: vfdshprop.cpp:60
LPARAM lParam
Definition: combotst.c:139
#define PROPSHEETPAGE
Definition: prsht.h:371

◆ DoVfdClose()

DWORD CVfdShExt::DoVfdClose ( HWND  hParent)

Definition at line 484 of file vfdshmenu.cpp.

486 {
487  return VfdGuiClose(hParent, m_nDevice);
488 }
ULONG m_nDevice
Definition: vfdshext.h:26
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
DWORD WINAPI VfdGuiClose(HWND hParent, ULONG nDevice)
Definition: vfdguiut.c:114

Referenced by DoVfdDrop(), InvokeCommand(), and VfdPageDlgProc().

◆ DoVfdDrop()

DWORD CVfdShExt::DoVfdDrop ( HWND  hParent)

Definition at line 529 of file vfdshmenu.cpp.

531 {
532  HANDLE hDevice;
533  DWORD file_attr;
536 
537  VFD_DISKTYPE disk_type;
538  VFD_MEDIA media_type;
539 
540  DWORD ret;
541 
542  VFDTRACE(0, ("CVfdShExt::DoVfdDropOpen()\n"));
543 
544  // check if dropped file is a valid image
545 
547  m_sTarget, &file_attr, &file_type, &file_size);
548 
549  if (ret != ERROR_SUCCESS) {
550  return ret;
551  }
552 
553  // check file size
554  media_type = VfdLookupMedia(file_size);
555 
556  if (!media_type) {
557  PSTR msg = ModuleMessage(MSG_FILE_TOO_SMALL);
558 
559  MessageBox(hParent, msg ? msg : "Bad size",
561 
562  if (msg) {
563  LocalFree(msg);
564  }
565 
566  return ERROR_CANCELLED;
567  }
568 
569  if ((file_type == VFD_FILETYPE_ZIP) ||
571 
572  disk_type = VFD_DISKTYPE_RAM;
573  }
574  else {
575  disk_type = VFD_DISKTYPE_FILE;
576  }
577 
578  // close current image (if opened)
579 
581 
582  if (ret != ERROR_SUCCESS &&
583  ret != ERROR_NOT_READY) {
584  return ret;
585  }
586 
587  // open dropped file
588 
589  hDevice = VfdOpenDevice(m_nDevice);
590 
591  if (hDevice == INVALID_HANDLE_VALUE) {
592  return GetLastError();
593  }
594 
595  ret = VfdOpenImage(
596  hDevice, m_sTarget, disk_type, media_type, FALSE);
597 
598  CloseHandle(hDevice);
599 
600  return ret;
601 }
PSTR ModuleMessage(DWORD nFormat,...)
Definition: vfdlib.c:124
#define CloseHandle
Definition: compat.h:406
DWORD DoVfdClose(HWND hParent)
Definition: vfdshmenu.cpp:484
#define ERROR_SUCCESS
Definition: deptool.c:10
#define VFD_MSGBOX_TITLE
Definition: vfdlib.h:53
UCHAR VFD_DISKTYPE
Definition: vfdtypes.h:60
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define MB_ICONSTOP
Definition: winuser.h:797
VFD_MEDIA WINAPI VfdLookupMedia(ULONG nSize)
Definition: vfdctl.c:3256
ULONG m_nDevice
Definition: vfdshext.h:26
#define ERROR_NOT_READY
Definition: winerror.h:124
CHAR m_sTarget[MAX_PATH]
Definition: vfdshext.h:27
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
unsigned long DWORD
Definition: ntddk_ex.h:95
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
FD_TYPE file_type(FDSC **curr, char *fixed)
Definition: file.c:221
#define FILE_ATTRIBUTE_COMPRESSED
Definition: nt_native.h:711
int ret
UCHAR VFD_FILETYPE
Definition: vfdtypes.h:62
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
#define MessageBox
Definition: winuser.h:5723
HANDLE WINAPI VfdOpenDevice(ULONG nTarget)
Definition: vfdctl.c:1215
#define FILE_ATTRIBUTE_ENCRYPTED
Definition: ntifs_ex.h:385
#define ERROR_CANCELLED
Definition: winerror.h:726
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
signed char * PSTR
Definition: retypes.h:7
DWORD WINAPI VfdCheckImageFile(PCSTR sFileName, PDWORD pAttributes, PVFD_FILETYPE pFileType, PULONG pImageSize)
Definition: vfdctl.c:3035
NTSTATUS VfdOpenImage(IN PDEVICE_EXTENSION DeviceExtension, IN PVFD_IMAGE_INFO ImageInfo)
Definition: vfdimg.c:104
#define msg(x)
Definition: auth_time.c:54
unsigned int ULONG
Definition: retypes.h:1
UCHAR VFD_MEDIA
Definition: vfdtypes.h:61
#define file_size(inode)
Definition: reiserfs_fs.h:1869

Referenced by InvokeCommand().

◆ DoVfdNew()

DWORD CVfdShExt::DoVfdNew ( HWND  hParent)

◆ DoVfdOpen()

DWORD CVfdShExt::DoVfdOpen ( HWND  hParent)

Definition at line 459 of file vfdshmenu.cpp.

461 {
463 
464  if (ret != ERROR_SUCCESS && ret != ERROR_CANCELLED) {
467  }
468 
469  return ret;
470 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define VFD_MSGBOX_TITLE
Definition: vfdlib.h:53
#define MB_ICONSTOP
Definition: winuser.h:797
ULONG m_nDevice
Definition: vfdshext.h:26
DWORD WINAPI VfdGuiOpen(HWND hParent, ULONG nDevice)
Definition: vfdguiopen.c:71
PCSTR SystemMessage(DWORD nError)
Definition: vfdlib.c:147
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
#define MessageBox
Definition: winuser.h:5723
#define ERROR_CANCELLED
Definition: winerror.h:726

Referenced by InvokeCommand(), and VfdPageDlgProc().

◆ DoVfdProtect()

DWORD CVfdShExt::DoVfdProtect ( HWND  hParent)

Definition at line 493 of file vfdshmenu.cpp.

495 {
496  HANDLE hDevice;
497  DWORD ret;
498 
500  VFDTRACE(0, ("CVfdShExt::DoVfdProtect()\n"));
501 
502  hDevice = VfdOpenDevice(m_nDevice);
503 
504  if (hDevice == INVALID_HANDLE_VALUE) {
505  return GetLastError();
506  }
507 
508  ret = VfdGetMediaState(hDevice);
509 
510  if (ret == ERROR_SUCCESS) {
511  ret = VfdWriteProtect(hDevice, TRUE);
512  }
513  else if (ret == ERROR_WRITE_PROTECT) {
514  ret = VfdWriteProtect(hDevice, FALSE);
515  }
516 
517  if (ret == ERROR_SUCCESS) {
518  ret = VfdGetMediaState(hDevice);
519  }
520 
521  CloseHandle(hDevice);
522 
523  return ret;
524 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
#define ERROR_SUCCESS
Definition: deptool.c:10
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define ERROR_WRITE_PROTECT
Definition: winerror.h:122
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
ULONG m_nDevice
Definition: vfdshext.h:26
DWORD WINAPI VfdWriteProtect(HANDLE hDevice, BOOL bProtect)
Definition: vfdctl.c:2484
DWORD WINAPI VfdGetMediaState(HANDLE hDevice)
Definition: vfdctl.c:1949
unsigned long DWORD
Definition: ntddk_ex.h:95
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
int ret
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
HANDLE WINAPI VfdOpenDevice(ULONG nTarget)
Definition: vfdctl.c:1215

Referenced by InvokeCommand(), and VfdPageDlgProc().

◆ DoVfdSave()

DWORD CVfdShExt::DoVfdSave ( HWND  hParent)

Definition at line 475 of file vfdshmenu.cpp.

477 {
478  return VfdGuiSave(hParent, m_nDevice);
479 }
ULONG m_nDevice
Definition: vfdshext.h:26
DWORD WINAPI VfdGuiSave(HWND hParent, ULONG nDevice)
Definition: vfdguisave.c:58
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22

Referenced by InvokeCommand(), and VfdPageDlgProc().

◆ GetCommandString()

STDMETHODIMP CVfdShExt::GetCommandString ( UINT  idCmd,
UINT  uFlags,
UINT reserved,
LPSTR  pszName,
UINT  cchMax 
)

Definition at line 269 of file vfdshmenu.cpp.

279 {
280  VFDTRACE(0,
281  ("CVfdShExt::GetCommandString(%u,...)\n", idCmd));
282 
284 
285  if (idCmd >= sizeof(g_VfdMenu) / sizeof(g_VfdMenu[0])) {
286  return S_FALSE;
287  }
288 
289  switch (uFlags) {
290  case GCS_HELPTEXTA:
294  g_hDllModule, g_VfdMenu[idCmd].helpid,
295  0, pszName, cchMax, NULL);
296 
297  VFDTRACE(0, ("HELPTEXTA: %s\n", pszName));
298  break;
299 
300  case GCS_HELPTEXTW:
304  g_hDllModule, g_VfdMenu[idCmd].helpid,
305  0, (LPWSTR)pszName, cchMax, NULL);
306 
307  VFDTRACE(0, ("HELPTEXTW: %ws\n", pszName));
308  break;
309 
310  case GCS_VERBA:
311  lstrcpynA(pszName, g_VfdMenu[idCmd].verbA, cchMax);
312  break;
313 
314  case GCS_VERBW:
315  lstrcpynW((LPWSTR)pszName, g_VfdMenu[idCmd].verbW, cchMax);
316  break;
317  }
318 
319  return NOERROR;
320 }
static const WCHAR verbW[]
Definition: main.c:64
#define NOERROR
Definition: winerror.h:2354
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
DWORD WINAPI FormatMessageA(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:483
UINT uFlags
Definition: api.c:59
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
#define lstrcpynW
Definition: compat.h:405
r reserved
Definition: btrfs.c:2865
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:403
static struct _vfd_menu g_VfdMenu[VFD_CMD_MAX]
HINSTANCE g_hDllModule
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
UINT cchMax
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:401
#define lstrcpynA
Definition: compat.h:416
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ GetDevice()

ULONG CVfdShExt::GetDevice ( )
inline

Definition at line 44 of file vfdshext.h.

44 { return m_nDevice; }
ULONG m_nDevice
Definition: vfdshext.h:26

Referenced by VfdPageDlgProc().

◆ GetTarget()

PCSTR CVfdShExt::GetTarget ( )
inline

Definition at line 45 of file vfdshext.h.

45 { return m_sTarget; }
CHAR m_sTarget[MAX_PATH]
Definition: vfdshext.h:27

◆ Initialize()

STDMETHODIMP CVfdShExt::Initialize ( LPCITEMIDLIST  pIDFolder,
LPDATAOBJECT  pDataObj,
HKEY  hKeyID 
)

Definition at line 121 of file vfdshext.cpp.

125 {
126  CHAR drive = '\0';
127 
128  VFDTRACE(0, ("CVfdShExt::Initialize()\n"));
129 
130  UNREFERENCED_PARAMETER(hRegKey);
131 
132  // Initialize can be called more than once
133 
134  if (m_pDataObj) {
135  m_pDataObj->Release();
136  m_pDataObj = NULL;
137  }
138 
139  m_nDevice = (ULONG)-1;
140  m_sTarget[0] = '\0';
141 
142  // Get the folder name
143  if (SHGetPathFromIDList(pIDFolder, m_sTarget)) {
144 
145  // act as a Drag-and-Drop Handler
146 
147  VFDTRACE(0, ("Drag-Drop: %s\n", m_sTarget));
148 
150  VFDTRACE(0, ("Not a VFD drive\n"));
151  return NOERROR;
152  }
153 
154  drive = m_sTarget[0];
155  m_bDragDrop = TRUE;
156  }
157  else {
158 
159  // act as a context menu handler
160 
161  VFDTRACE(0, ("Context menu:\n"));
162  m_bDragDrop = FALSE;
163  }
164 
165  // Extract the target object name
166 
167  if (pDataObj) {
168 
169  STGMEDIUM medium;
170  FORMATETC fmt = {
171  CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL
172  };
173 
174  if (SUCCEEDED(pDataObj->GetData(&fmt, &medium))) {
175  if (DragQueryFile((HDROP)medium.hGlobal, (UINT)-1, NULL, 0)) {
176 
177  DragQueryFile((HDROP)medium.hGlobal,
178  0, m_sTarget, sizeof(m_sTarget));
179  }
180 
181  ReleaseStgMedium(&medium);
182  }
183  }
184 
185  VFDTRACE(0, ("Target %s\n", m_sTarget));
186 
187  if (!drive) {
188  // Contect menu handler
189  // -- Data object is the target drive
190  drive = m_sTarget[0];
191  }
192 
193  HANDLE hDevice = VfdOpenDevice(drive);
194 
195  if (hDevice == INVALID_HANDLE_VALUE) {
196  VFDTRACE(0, ("Not a VFD drive\n"));
197  return NOERROR;
198  }
199 
200  ULONG ret = VfdGetDeviceNumber(hDevice, &m_nDevice);
201 
202  CloseHandle(hDevice);
203 
204  if (ret != ERROR_SUCCESS) {
205  m_nDevice = (ULONG)-1;
206  return NOERROR;
207  }
208 
209  VFDTRACE(0, ("VFD device %d\n", m_nDevice));
210  // Store the data object
211 
212  m_pDataObj = pDataObj;
213  m_pDataObj->AddRef();
214 
215  return NOERROR;
216 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NOERROR
Definition: winerror.h:2354
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define GetDriveType
Definition: winbase.h:3636
LPDATAOBJECT m_pDataObj
Definition: vfdshext.h:25
char CHAR
Definition: xmlstorage.h:175
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#define DRIVE_REMOVABLE
Definition: winbase.h:248
DWORD WINAPI VfdGetDeviceNumber(HANDLE hDevice, PULONG pNumber)
Definition: vfdctl.c:2359
BOOL m_bDragDrop
Definition: vfdshext.h:28
ULONG m_nDevice
Definition: vfdshext.h:26
smooth NULL
Definition: ftsmooth.c:416
#define CF_HDROP
Definition: constants.h:410
CHAR m_sTarget[MAX_PATH]
Definition: vfdshext.h:27
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
int ret
HANDLE WINAPI VfdOpenDevice(ULONG nTarget)
Definition: vfdctl.c:1215
#define SHGetPathFromIDList
Definition: shlobj.h:209
unsigned int UINT
Definition: ndis.h:50
#define DragQueryFile
Definition: shellapi.h:682
unsigned int ULONG
Definition: retypes.h:1
Definition: dsound.c:943
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ InvokeCommand()

STDMETHODIMP CVfdShExt::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpcmi)

Implements IContextMenu.

Definition at line 332 of file vfdshmenu.cpp.

334 {
335  VFDTRACE(0, ("CVfdShExt::InvokeCommand()\n"));
336 
337  BOOL unicode = FALSE;
338  UINT id;
339  DWORD ret;
341 
342  if (lpcmi->cbSize >= sizeof(CMINVOKECOMMANDINFOEX) &&
343  (lpcmi->fMask & CMIC_MASK_UNICODE)) {
344 
345  unicode = TRUE;
346  }
347 
348 
349  if (!unicode && HIWORD(lpcmi->lpVerb)) {
350 
351  VFDTRACE(0, ("ANSI: %s\n", lpcmi->lpVerb));
352 
353  // ANSI verb
354  for (id = 0; id < sizeof(g_VfdMenu) / sizeof(g_VfdMenu[0]); id++) {
355  if (!lstrcmpi(lpcmi->lpVerb, g_VfdMenu[id].verbA)) {
356  break;
357  }
358  }
359  }
360  else if (unicode && HIWORD(excmi->lpVerbW)) {
361 
362  VFDTRACE(0, ("UNICODE: %ws\n", excmi->lpVerbW));
363 
364  // UNICODE verb
365  for (id = 0; id < sizeof(g_VfdMenu) / sizeof(g_VfdMenu[0]); id++) {
366  if (!lstrcmpiW(excmi->lpVerbW, g_VfdMenu[id].verbW)) {
367  break;
368  }
369  }
370  }
371  else {
372 
373  VFDTRACE(0, ("Command: %u\n", LOWORD(lpcmi->lpVerb)));
374 
375  // Command ID
376  id = LOWORD(lpcmi->lpVerb);
377  }
378 
379  VFDTRACE(0, ("MenuItem: %u\n", id));
380 
381  switch (id) {
382  case VFD_CMD_OPEN:
383  ret = DoVfdOpen(lpcmi->hwnd);
384 
385  if (ret == ERROR_SUCCESS) {
386  VfdImageTip(lpcmi->hwnd, m_nDevice);
387  }
388  break;
389 
390  case VFD_CMD_SAVE:
391  ret = DoVfdSave(lpcmi->hwnd);
392  break;
393 
394  case VFD_CMD_CLOSE:
395  ret = DoVfdClose(lpcmi->hwnd);
396  break;
397 
398  case VFD_CMD_PROTECT:
399  ret = DoVfdProtect(lpcmi->hwnd);
400 
401  if (ret == ERROR_SUCCESS) {
402  VfdImageTip(lpcmi->hwnd, m_nDevice);
403  }
404  else if (ret == ERROR_WRITE_PROTECT) {
405  VfdImageTip(lpcmi->hwnd, m_nDevice);
406  ret = ERROR_SUCCESS;
407  }
408  break;
409 
410  case VFD_CMD_DROP:
411  ret = DoVfdDrop(lpcmi->hwnd);
412 
413  if (ret == ERROR_SUCCESS) {
414  VfdImageTip(lpcmi->hwnd, m_nDevice);
415  }
416  break;
417 
418  case VFD_CMD_PROP:
419  {
420  SHOBJECTPROPERTIES pSHObjectProperties;
421  WCHAR path[4] = L" :\\";
422 
423  pSHObjectProperties = (SHOBJECTPROPERTIES)GetProcAddress(
424  LoadLibrary("shell32"), "SHObjectProperties");
425 
426  if (!pSHObjectProperties) {
427  pSHObjectProperties = (SHOBJECTPROPERTIES)GetProcAddress(
428  LoadLibrary("shell32"), (LPCSTR)SHOP_EXPORT_ORDINAL);
429  }
430 
431  if (pSHObjectProperties) {
432  path[0] = m_sTarget[0];
433 
434  pSHObjectProperties(lpcmi->hwnd,
435  SHOP_FILEPATH, path, L"VFD");
436  }
437  }
438  ret = ERROR_SUCCESS;
439  break;
440 
441  default:
442  return E_INVALIDARG;
443  }
444 
445  if (ret != ERROR_SUCCESS &&
446  ret != ERROR_CANCELLED) {
447 
448  MessageBox(lpcmi->hwnd,
450  }
451 
452  return NOERROR;
453 }
#define SHOP_FILEPATH
Definition: vfdshmenu.cpp:36
#define TRUE
Definition: types.h:120
#define lstrcmpi
Definition: winbase.h:3697
DWORD DoVfdClose(HWND hParent)
Definition: vfdshmenu.cpp:484
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD DoVfdOpen(HWND hParent)
Definition: vfdshmenu.cpp:459
#define LoadLibrary
Definition: winbase.h:3686
#define VFD_MSGBOX_TITLE
Definition: vfdlib.h:53
#define NOERROR
Definition: winerror.h:2354
#define ERROR_WRITE_PROTECT
Definition: winerror.h:122
DWORD DoVfdProtect(HWND hParent)
Definition: vfdshmenu.cpp:493
#define MB_ICONSTOP
Definition: winuser.h:797
DWORD DoVfdSave(HWND hParent)
Definition: vfdshmenu.cpp:475
DWORD DoVfdDrop(HWND hParent)
Definition: vfdshmenu.cpp:529
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG m_nDevice
Definition: vfdshext.h:26
#define E_INVALIDARG
Definition: ddrawi.h:101
const char * LPCSTR
Definition: xmlstorage.h:183
static struct _vfd_menu g_VfdMenu[VFD_CMD_MAX]
#define SHOP_EXPORT_ORDINAL
Definition: vfdshmenu.cpp:39
__wchar_t WCHAR
Definition: xmlstorage.h:180
PCSTR SystemMessage(DWORD nError)
Definition: vfdlib.c:147
CHAR m_sTarget[MAX_PATH]
Definition: vfdshext.h:27
unsigned long DWORD
Definition: ntddk_ex.h:95
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
int ret
static const WCHAR L[]
Definition: oid.c:1250
BOOL(WINAPI * SHOBJECTPROPERTIES)(HWND hwnd, DWORD dwType, LPCWSTR lpObject, LPCWSTR lpPage)
Definition: vfdshmenu.cpp:32
#define MessageBox
Definition: winuser.h:5723
void WINAPI VfdImageTip(HWND hParent, ULONG nDevice)
Definition: vfdguitip.c:266
#define ERROR_CANCELLED
Definition: winerror.h:726
Definition: services.c:325
struct IContextMenu::tagCMInvokeCommandInfoEx CMINVOKECOMMANDINFOEX
unsigned int UINT
Definition: ndis.h:50
#define HIWORD(l)
Definition: typedefs.h:246
GLenum GLuint id
Definition: glext.h:5579
#define GetProcAddress(x, y)
Definition: compat.h:418
#define LOWORD(l)
Definition: pedump.c:82

◆ QueryContextMenu()

STDMETHODIMP CVfdShExt::QueryContextMenu ( HMENU  hMenu,
UINT  indexMenu,
UINT  idCmdFirst,
UINT  idCmdLast,
UINT  uFlags 
)

Implements IContextMenu.

Definition at line 106 of file vfdshmenu.cpp.

112 {
113  UNREFERENCED_PARAMETER(idCmdLast);
114  VFDTRACE(0, ("CVfdShExt::QueryContextMenu()\n"));
115 
116  //
117  // Check if menu items should be added
118  //
119  if ((CMF_DEFAULTONLY & uFlags) ||
120  !m_pDataObj || m_nDevice == (ULONG)-1) {
121 
122  VFDTRACE(0, ("Don't add any items.\n"));
123  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 0);
124  }
125 
126  //
127  // Drag & Drop handler?
128  //
129  if (m_bDragDrop) {
130 
131  VFDTRACE(0, ("Invoked as the Drop handler.\n"));
132 
134 
135  // if the dropped item is a directory, nothing to do here
136  VFDTRACE(0, ("Dropped object is a directory.\n"));
137 
138  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 0);
139  }
140 
141  // Add a drop context menu item
142  AddMenuItem(
143  hMenu,
144  indexMenu,
146  idCmdFirst + VFD_CMD_DROP,
147  g_VfdMenu[VFD_CMD_DROP].textid);
148 
150  }
151 
152  //
153  // Context menu handler
154  //
155  VFDTRACE(0, ("Invoked as the context menu handler.\n"));
156 
157  //
158  // Get the VFD media state
159  //
160  HANDLE hDevice = VfdOpenDevice(m_nDevice);
161 
162  if (hDevice == INVALID_HANDLE_VALUE) {
163  VFDTRACE(0, ("device open failed.\n"));
164  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 0);
165  }
166 
167  DWORD status = VfdGetMediaState(hDevice);
168 
169  CloseHandle(hDevice);
170 
171  //
172  // Add context menu items
173  //
174 
175  InsertMenu(hMenu, indexMenu++,
177 
178  if (status == ERROR_SUCCESS ||
180 
181  // An image is opened
182 
183  // insert the "save" menu item
184 
185  AddMenuItem(
186  hMenu,
187  indexMenu++,
189  idCmdFirst + VFD_CMD_SAVE,
190  g_VfdMenu[VFD_CMD_SAVE].textid);
191 
192  // insert the "close" menu item
193 
194  AddMenuItem(
195  hMenu,
196  indexMenu++,
198  idCmdFirst + VFD_CMD_CLOSE,
199  g_VfdMenu[VFD_CMD_CLOSE].textid);
200 
201  // insert the "protect" menu item
202 
203  AddMenuItem(
204  hMenu,
205  indexMenu++,
207  idCmdFirst + VFD_CMD_PROTECT,
208  g_VfdMenu[VFD_CMD_PROTECT].textid);
209 
210  // check "protect" menu item
211 
212  if (status == ERROR_WRITE_PROTECT) {
213  CheckMenuItem(hMenu, indexMenu - 1,
215  }
216  }
217  else {
218  // The drive is empty
219 
220  // insert the "open" menu item
221 
222  AddMenuItem(
223  hMenu,
224  indexMenu++,
226  idCmdFirst + VFD_CMD_OPEN,
227  g_VfdMenu[VFD_CMD_OPEN].textid);
228  }
229 
230  // Insert the "proterty" menu item
231 
232  AddMenuItem(
233  hMenu,
234  indexMenu++,
236  idCmdFirst + VFD_CMD_PROP,
237  g_VfdMenu[VFD_CMD_PROP].textid);
238 
239  // Insert a separator
240 
241  InsertMenu(hMenu, indexMenu,
243 
245 }
static void AddMenuItem(HMENU hMenu, UINT uPos, UINT uFlags, UINT uCmd, UINT uText)
Definition: vfdshmenu.cpp:77
#define CloseHandle
Definition: compat.h:406
#define ERROR_SUCCESS
Definition: deptool.c:10
#define InsertMenu
Definition: winuser.h:5704
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define ERROR_WRITE_PROTECT
Definition: winerror.h:122
LPDATAOBJECT m_pDataObj
Definition: vfdshext.h:25
#define MF_STRING
Definition: winuser.h:138
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
UINT uFlags
Definition: api.c:59
#define SEVERITY_SUCCESS
Definition: winerror.h:64
BOOL m_bDragDrop
Definition: vfdshext.h:28
#define MF_BYPOSITION
Definition: winuser.h:203
ULONG m_nDevice
Definition: vfdshext.h:26
smooth NULL
Definition: ftsmooth.c:416
#define MF_SEPARATOR
Definition: winuser.h:137
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
static struct _vfd_menu g_VfdMenu[VFD_CMD_MAX]
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define MF_CHECKED
Definition: winuser.h:132
CHAR m_sTarget[MAX_PATH]
Definition: vfdshext.h:27
DWORD WINAPI VfdGetMediaState(HANDLE hDevice)
Definition: vfdctl.c:1949
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
HANDLE WINAPI VfdOpenDevice(ULONG nTarget)
Definition: vfdctl.c:1215
#define GetFileAttributes
Definition: winbase.h:3639
unsigned int ULONG
Definition: retypes.h:1
Definition: ps.c:97

◆ QueryInterface()

STDMETHODIMP CVfdShExt::QueryInterface ( REFIID  riid,
LPVOID ppv 
)

Definition at line 55 of file vfdshext.cpp.

58 {
59  *ppv = NULL;
60 
61  if (IsEqualIID(riid, IID_IShellExtInit) ||
63  VFDTRACE(0,
64  ("CVfdShExt::QueryInterface()==>IID_IShellExtInit\n"));
65 
66  *ppv = (LPSHELLEXTINIT)this;
67  }
68  else if (IsEqualIID(riid, IID_IContextMenu)) {
69  VFDTRACE(0,
70  ("CVfdShExt::QueryInterface()==>IID_IContextMenu\n"));
71 
72  *ppv = (LPCONTEXTMENU)this;
73  }
74  else if (IsEqualIID(riid, IID_IShellPropSheetExt)) {
75  VFDTRACE(0,
76  ("CVfdShExt::QueryInterface()==>IID_IShellPropSheetExt\n"));
77 
78  *ppv = (LPSHELLPROPSHEETEXT)this;
79  }
80 
81  if (*ppv) {
82  AddRef();
83 
84  return NOERROR;
85  }
86 
87  VFDTRACE(0,
88  ("CVfdShExt::QueryInterface()==>Unknown Interface!\n"));
89 
90  return E_NOINTERFACE;
91 }
#define E_NOINTERFACE
Definition: winerror.h:2364
#define NOERROR
Definition: winerror.h:2354
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
CMIC_MASK_NOZONECHECKS typedef IContextMenu * LPCONTEXTMENU
Definition: shobjidl.idl:1648
smooth NULL
Definition: ftsmooth.c:416
IShellExtInit * LPSHELLEXTINIT
Definition: shobjidl.idl:1273
const GUID IID_IUnknown
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
ULONG AddRef()
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

Referenced by CVfdFactory::CreateInstance().

◆ ReplacePage()

STDMETHODIMP CVfdShExt::ReplacePage ( UINT  uPageID,
LPFNADDPROPSHEETPAGE  lpfnReplaceWith,
LPARAM  lParam 
)

Definition at line 454 of file vfdshprop.cpp.

458 {
459  UNREFERENCED_PARAMETER(uPageID);
460  UNREFERENCED_PARAMETER(lpfnReplaceWith);
462  return E_FAIL;
463 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define E_FAIL
Definition: ddrawi.h:102
LPARAM lParam
Definition: combotst.c:139

◆ STDMETHODIMP_() [1/2]

CVfdShExt::STDMETHODIMP_ ( ULONG  )

◆ STDMETHODIMP_() [2/2]

CVfdShExt::STDMETHODIMP_ ( ULONG  )

Member Data Documentation

◆ m_bDragDrop

BOOL CVfdShExt::m_bDragDrop
protected

Definition at line 28 of file vfdshext.h.

Referenced by CVfdShExt(), Initialize(), and QueryContextMenu().

◆ m_cRefCnt

ULONG CVfdShExt::m_cRefCnt
protected

Definition at line 24 of file vfdshext.h.

Referenced by CVfdShExt(), and STDMETHODIMP_().

◆ m_nDevice

ULONG CVfdShExt::m_nDevice
protected

◆ m_pDataObj

LPDATAOBJECT CVfdShExt::m_pDataObj
protected

Definition at line 25 of file vfdshext.h.

Referenced by AddPages(), CVfdShExt(), Initialize(), QueryContextMenu(), and ~CVfdShExt().

◆ m_sTarget

CHAR CVfdShExt::m_sTarget[MAX_PATH]
protected

Definition at line 27 of file vfdshext.h.

Referenced by CVfdShExt(), DoVfdDrop(), GetTarget(), Initialize(), InvokeCommand(), and QueryContextMenu().


The documentation for this class was generated from the following files: