?? pci.cpp
字號:
// pci.cpp : implementation file
//
#include "stdafx.h"
#include "pctest.h"
#include "pci.h"
#include "adc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern PCHAR mDynVxDName;
/////////////////////////////////////////////////////////////////////////////
// Cpci dialog
Cpci::Cpci(CWnd* pParent /*=NULL*/)
: CDialog(Cpci::IDD, pParent)
{
//{{AFX_DATA_INIT(Cpci)
m_irq = 0;
m_io2 = _T("");
m_mem = _T("");
m_io1 = _T("");
//}}AFX_DATA_INIT
hDevice=NULL;
}
void Cpci::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Cpci)
DDX_Text(pDX, IDC_EDIT5, m_irq);
DDX_Text(pDX, IDC_EDIT4, m_io2);
DDX_Text(pDX, IDC_EDIT6, m_mem);
DDX_Text(pDX, IDC_EDIT7, m_io1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Cpci, CDialog)
//{{AFX_MSG_MAP(Cpci)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Cpci message handlers
BOOL Cpci::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
if(hDevice==NULL)
{
hDevice = CreateFile(mDynVxDName,//"\\\\.\\MatyDevice0",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,
NULL);
if (hDevice == INVALID_HANDLE_VALUE)
{
AfxMessageBox("請檢查板卡和驅動程序");
CDialog::OnCancel();
return FALSE;
}
}
pci=(pci_cfg*)malloc(sizeof(pci_cfg));
BOOL status = DeviceIoControl(
hDevice,
2236432,//IOCTL_PCI_CON,//0x222010
NULL,
0,
pci,
sizeof(pci_cfg),
&nRet,
NULL);
m_irq=pci->IRQ;
m_io1.Format("%x", pci->IOBase[0]);
m_io2.Format("%x", pci->IOBase[1]);
m_mem.Format("%x",pci->MemBase);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void Cpci::OnOK()
{
// TODO: Add extra validation here
if(hDevice!=NULL)
{
CloseHandle( hDevice);
hDevice=NULL;
}
CDialog::OnOK();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -