📄 spectrdevice.cpp
字号:
// SpectrDevice.cpp: implementation of the SpectrDevice class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "DriverTestA.h"
#include "SpectrDevice.h"
#include "winioctl.h"
#include "devintf.h"
#include "setupapi.h"
#include "intrface.h"
//#include "test1ioctl.h"
#include "Test1DeviceInterface.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
HANDLE OpenByInterface(GUID* pClassGuid, DWORD instance, PDWORD pError);
GUID ClassGuid = GUID_DEVINTERFACE_D12USB;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
SpectrDevice::SpectrDevice()
{
}
SpectrDevice::~SpectrDevice()
{
}
DWORD SpectrDevice::InitDevice()
{
DWORD dError = 0;
hDevice = OpenByInterface( &ClassGuid, 0, &dError);
if (hDevice == INVALID_HANDLE_VALUE)
{
CString error;
error.Format("设备不可用,错误号(%d),请重新连接!", dError);
AfxMessageBox(error);
return dError;
}
else
{
AfxMessageBox("设备可使用!");
}
return ERROR_SUCCESS;
}
DWORD SpectrDevice::StartCap()
{
ULONG nOutput;
BOOL bResult;
unsigned char Buffer[16];
memset(Buffer, 0, 16);
bResult = DeviceIoControl( hDevice,
D12_START,
Buffer,
sizeof(Buffer),
Buffer,
sizeof(Buffer),
&nOutput,
NULL);
if( !bResult )
{
DWORD dError = GetLastError();
CString error;
error.Format("ERROR: %d", dError);
AfxMessageBox(error);
return dError;
}
return ERROR_SUCCESS;
}
DWORD SpectrDevice::StopCap()
{
ULONG nOutput;
unsigned char Buffer[256];
if( !DeviceIoControl(hDevice, D12_END, Buffer, 256, Buffer, 256, &nOutput, NULL) )
{
DWORD dError = GetLastError();
CString error;
error.Format("ERROR: %d", dError);
AfxMessageBox(error);
return dError;
}
return ERROR_SUCCESS;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -