// PWDG2Dlg.cpp : implementation file // #include "stdafx.h" #include "PCIWDG2.h" #include "PWDG2Dlg.h" #include "ACCES32.h" #define MyKey "Software\\PCIFIND\\NTioPCI\\Parameters" TPCI_COMMON_CONFIG buf[64]; unsigned long BaseAddr; bool Running; bool RunFlag; #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CPCIWDG2Dlg dialog CPCIWDG2Dlg::CPCIWDG2Dlg(CWnd* pParent /*=NULL*/) : CDialog(CPCIWDG2Dlg::IDD, pParent) { //{{AFX_DATA_INIT(CPCIWDG2Dlg) m_BaseAddress = _T(" Base Address: 0000"); m_Temperature = _T(" Temperature (F): 00.0"); m_CounterCheck = _T("_"); m_TemperatureCheck = _T("_"); m_DI0Check = _T("_"); m_DI1Check = _T("_"); m_FanCheck = _T("_"); m_VoltageHighCheck = _T("_"); m_VoltageLowCheck = _T("_"); m_InterruptCheck = _T("_"); m_Base4 = _T(" Base + 4: 00"); m_Base5 = _T(" Base + 5: 00"); m_ISABase = _T("300"); //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CPCIWDG2Dlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPCIWDG2Dlg) DDX_Control(pDX, IDC_ISAEDIT, m_IsaEditCtrl); DDX_Text(pDX, IDC_BASE, m_BaseAddress); DDX_Text(pDX, IDC_ISAEDIT, m_ISABase); DDX_Text(pDX, IDC_TEMP, m_Temperature); DDX_Text(pDX, IDC_CHECK1, m_CounterCheck); DDX_Text(pDX, IDC_CHECK2, m_TemperatureCheck); DDX_Text(pDX, IDC_CHECK3, m_DI0Check); DDX_Text(pDX, IDC_CHECK4, m_DI1Check); DDX_Text(pDX, IDC_CHECK5, m_FanCheck); DDX_Text(pDX, IDC_CHECK6, m_VoltageHighCheck); DDX_Text(pDX, IDC_CHECK7, m_VoltageLowCheck); DDX_Text(pDX, IDC_CHECK8, m_InterruptCheck); DDX_Text(pDX, IDC_BASE4, m_Base4); DDX_Text(pDX, IDC_BASE5, m_Base5); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CPCIWDG2Dlg, CDialog) //{{AFX_MSG_MAP(CPCIWDG2Dlg) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDCANCEL, OnExitButton) ON_BN_CLICKED(IDOK, OnTestButton) ON_WM_TIMER() ON_WM_SHOWWINDOW() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPCIWDG2Dlg message handlers BOOL CPCIWDG2Dlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon if (InPortB(0x61) == 0xAA55) { MessageBox("ACCESNT.SYS not detected. Please copy ACCESNT.SYS into [NT]/system32/drivers and re-run this sample.", "Warning", MB_OK); } // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CPCIWDG2Dlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CPCIWDG2Dlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } void CPCIWDG2Dlg::OnExitButton() { KillTimer(0); exit(0); } void CPCIWDG2Dlg::FindCards(void) { bool found; HKEY Key; DWORD DataType, DataSize, num, i; found = false; RegOpenKeyEx(HKEY_LOCAL_MACHINE, MyKey, 0, KEY_READ, &Key); DataSize = sizeof(num); RegQueryValueEx(Key, "NumDevices", NULL, &DataType, (PUCHAR)&num, &DataSize); if (num > 0) { DataSize = num * sizeof(TPCI_COMMON_CONFIG); RegQueryValueEx(Key, "PCICommonConfig", NULL, &DataType, (PUCHAR)buf, &DataSize); } for (i=0; i