querydosdevice.cpp

来自「IO函数调用测试」· C++ 代码 · 共 98 行

CPP
98
字号
// QueryDosDevice.cpp : implementation file
//

#include "stdafx.h"
#include "IOExplorer.h"

#include "DataListBox.h"
  #include "QueryDosDevice.h"

#include "format.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CQueryDosDevice property page

IMPLEMENT_DYNCREATE(CQueryDosDevice, CPropertyPage)

CQueryDosDevice::CQueryDosDevice() : CPropertyPage(CQueryDosDevice::IDD)
{
	//{{AFX_DATA_INIT(CQueryDosDevice)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	lastsel = -1;
}

CQueryDosDevice::~CQueryDosDevice()
{
}

void CQueryDosDevice::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CQueryDosDevice)
	DDX_Control(pDX, IDC_DEVICE, c_Device);
	DDX_Control(pDX, IDC_RESULT, c_Result);
	DDX_Control(pDX, IDC_LIST, c_List);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CQueryDosDevice, CPropertyPage)
	//{{AFX_MSG_MAP(CQueryDosDevice)
	ON_LBN_SELCHANGE(IDC_LIST, OnSelchangeList)
	ON_LBN_SELCHANGE(IDC_DEVICE, OnSelchangeDevice)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CQueryDosDevice message handlers

#define LIMIT 16384

/****************************************************************************
*                         CQueryDosDevice::expandText
* Inputs:
*       CString s: Text to be expanded
*	CDataListBox & list: Place to add expansion
*	DWORD & size: Size to use for buffer
* Result: BOOL
*       TRUE if successful
*	FALSE if error
* Effect: 
*       Expands the string by doing QueryDosDevice
****************************************************************************/

BOOL CQueryDosDevice::expandText(LPCTSTR s, CDataListBox & list, DWORD & size)
    {
     size = 1024;
     LPTSTR buffer = new TCHAR[size];

     while(TRUE)
        { /* try fetching */
	 if(QueryDosDevice(s, buffer, size) == 0)
	    { /* failed */
	     size *= 2;
	     if(size > LIMIT)
		{ /* no good */
		 return FALSE;
		} /* no good */
	     delete [] buffer;
	     buffer = new TCHAR[size];
	    } /* failed */

	 multiStringToControl(s, buffer, list);
	 delete [] buffer;
	 return TRUE;
	} /* try fetching */
    }

/****************************************************************************
*                         CQueryDosDevice::newResult
* Inputs:
*       

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?