summaryrefslogtreecommitdiff
path: root/NSCmpts/DeleteSwapFile.cpp
blob: 5e89f446ef05efa518808d14d979888728d74b96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// DeleteSwapFile.cpp : Implementation of CDeleteSwapFile
#include "stdafx.h"
#include "NSCmpts.h"
#include "DeleteSwapFile.h"
#include "../Common/Defines.h"
#include <mystring.h>
#include <appmisc.h>

/////////////////////////////////////////////////////////////////////////////
// CDeleteSwapFile

STDMETHODIMP CDeleteSwapFile::InterfaceSupportsErrorInfo(REFIID riid)
{
	static const IID* arr[] = 
	{
		&IID_ISecureShutdownDOS,
	};
	for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
	{
		if (InlineIsEqualGUID(*arr[i],riid))
			return S_OK;
	}
	return S_FALSE;
}

//////////////////////////////////////////////////////////////////////
// This won't run under Windows NT so don't even show it

HRESULT CDeleteSwapFile::FinalConstruct()
{
	if(::GetVersion() < 0x80000000)
		return E_FAIL;
	else
		return S_OK;
}

/////////////////////////////////////////////////////////////////////////////
// Returns text to put in Batch File

STDMETHODIMP CDeleteSwapFile::GetBatchText(BSTR* psText)
{
	// This should never be true as the object shouldn't 
	// even be creatable under WIN NT;
	// ASSERT(::GetPlatform() == VER_PLATFORM_WIN32_NT);
	ASSERT(::GetVersion() >= 0x80000000);

	// Format and return string
	string sRetVal;
	string sWinFolder;

	if(!GetWindowsDirectory(sWinFolder.get_buffer(MAX_PATH), MAX_PATH))
		sWinFolder = _T("C:\\WINDOWS");

	sRetVal.format(IDS_DELSWAP_BATCHTEXT, (LPCTSTR)sWinFolder, (LPCTSTR)sWinFolder);

	CComBSTR bsRet(sRetVal);
	*psText = bsRet.Detach();

	return S_OK;
}

////////////////////////////////////////////////////////
// Called to initialize our data object

STDMETHODIMP CDeleteSwapFile::SetData(IUnknown* pUnk)
{
	// Just let CProperty Bag do it
	return m_Data.Initialize(pUnk);
}

////////////////////////////////////////////////////////
// Returns Info about our object

STDMETHODIMP CDeleteSwapFile::get_Info(NightSecInfo nsItem, VARIANT* pvVal)
{
	::VariantClear(pvVal);

	CComBSTR bsRetVal;
	switch(nsItem)
	{
	case nsName:
		pvVal->vt = VT_BSTR;
		bsRetVal.LoadString(IDS_DELSWAP_NAME);
		pvVal->bstrVal = bsRetVal.Detach();
		return S_OK;
	case nsHelpText:
		pvVal->vt = VT_BSTR;
		bsRetVal.LoadString(IDS_DELSWAP_DESC);
		pvVal->bstrVal = bsRetVal.Detach();
		return S_OK;
	}

	::VariantClear(pvVal);
	return S_FALSE;
}