1
0

Detect availabl drive letters

This commit is contained in:
Scott Graves
2017-02-16 14:41:13 -06:00
parent 4de32f835a
commit b7aad55510
4 changed files with 33 additions and 24 deletions

View File

@@ -1,7 +1,8 @@
<HTML>
<meta http-equiv="X-UA-Compatible" content="IE=10" />
<HEAD>
</HEAD>
<BODY ID=CSiaDriveDlg BGCOLOR=LIGHTGREY style="font-family: MS Shell Dlg; font-size: 14">
<BODY ID=CSiaDriveDlg BGCOLOR=LIGHTGREY>
<h3 style="margin-bottom: 5px">Sia Information</h3>
<div style="float: right;">
<table>
@@ -36,7 +37,7 @@
</div>
<div style="position: absolute; bottom: 10; left: 10; width: 100%">
<div style="position: absolute; bottom: 10; width: 100%">
<table width="100%">
<TR width=100%">
<TD ALIGN=RIGHT VALIGN=BOTTOM>

View File

@@ -7,6 +7,7 @@
#include "SiaDriveDlg.h"
#include "afxdialogex.h"
#include <stdbool.h>
#include <bitset>
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -18,8 +19,28 @@ wept saxophone dialect depth update jaunt loincloth asleep lush gnome laptop upp
* Work Test
names amaze when afraid inmate hull hexagon etched niece rudely tudor unopened acidic swagger emit shrugged noises tycoon leech tubes shrugged bulb inexact plywood tuesday rims cease excess aces
* Work Test2
ornament alkaline gasp pepper upkeep ablaze number sizes toyed sawmill looking bygones dwarf nerves session cake jerseys niche arrow howls omission verification identity waffle pockets giving hiding river acoustic
*/
static std::set<std::string> GetAvailableDrives()
{
static const std::vector<char> alpha = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
std::bitset<sizeof(DWORD) * 8> drives(~GetLogicalDrives());
std::set<std::string> avail;
for (size_t i = 0; i < alpha.size(); i++)
{
if (drives[i])
{
avail.insert(std::string(1, alpha[i]));
}
}
return std::move(avail);
}
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialogEx
@@ -96,7 +117,7 @@ END_MESSAGE_MAP()
BOOL CSiaDriveDlg::OnInitDialog()
{
CDHtmlDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
@@ -167,7 +188,7 @@ void CSiaDriveDlg::OnPaint()
}
}
BOOL CSiaDriveDlg::CallClientScript(LPCTSTR pStrFuncName, CStringArray* pArrFuncArgs, CComVariant* pOutVarRes)
BOOL CSiaDriveDlg::CallClientScript(LPCTSTR pStrFuncName, const json& json, CComVariant* pOutVarRes)
{
BOOL bRes = FALSE;
CComVariant vaResult;
@@ -183,24 +204,14 @@ BOOL CSiaDriveDlg::CallClientScript(LPCTSTR pStrFuncName, CStringArray* pArrFunc
DISPID dispid = NULL;
if (SUCCEEDED(spScript->GetIDsOfNames(IID_NULL, &bstrMember, 1, LOCALE_USER_DEFAULT, &dispid)))
{
COleSafeArray ar;
ar.CreateOneDim(VT_VARIANT, pArrFuncArgs->GetSize());
for (long i = 0; i < pArrFuncArgs->GetSize(); i++)
{
CComVariant v(pArrFuncArgs->GetAt(i));
ar.PutElement(&i, &v);
}
long l = 0;
COleSafeArray sa;
sa.CreateOneDim(VT_VARIANT, 1);
sa.PutElement(&l, ar);
VARIANT v[1];
v[0] = CComVariant(CA2W(json.dump().c_str()));
//Putting parameters
DISPPARAMS dispparams;
memset(&dispparams, 0, sizeof dispparams);
dispparams.cArgs = 1;
dispparams.rgvarg = sa;
dispparams.rgvarg = v;
dispparams.cNamedArgs = 0;
EXCEPINFO excepInfo;
@@ -275,11 +286,6 @@ HRESULT CSiaDriveDlg::OnButtonUnlockWallet(IHTMLElement* /*pElement*/)
HRESULT CSiaDriveDlg::OnButtonMount(IHTMLElement* /*pElement*/)
{
CStringArray driveList;
driveList.Add(L"S");
driveList.Add(L"T");
CallClientScript(L"setAvailableDrives", &driveList, nullptr);
return S_OK;
}
@@ -451,6 +457,7 @@ void CSiaDriveDlg::ConfigureWallet()
}
else
{
CallClientScript(L"setAvailableDrives", json(GetAvailableDrives()), nullptr);
SetMainWindow(L"tab_view");
switch (_siaConfig.GetUI_Main_TabIndex())

View File

@@ -57,7 +57,7 @@ private:
bool UpdateUi(const bool& refresh = true);
HRESULT GetDomNodeAndElementById(const String& id, CComPtr<IHTMLDOMNode>& node, CComPtr<IHTMLElement>& elem);
HRESULT GetDomNodeById(const String& id, CComPtr<IHTMLDOMNode>& node);
BOOL CallClientScript(LPCTSTR pStrFuncName, CStringArray* pArrFuncArgs, CComVariant* pOutVarRes);
BOOL CallClientScript(LPCTSTR pStrFuncName, const json& json, CComVariant* pOutVarRes);
private:
CSiaDriveConfig _siaConfig;

View File

@@ -1,7 +1,8 @@
function setAvailableDrives(driveList) {
alert(driveList[0]);
driveList = JSON.parse(driveList);
var sel = document.getElementById("MountDrives");
sel.innerHTML = "";