// IIRO8Dlg.cpp : implementation file // #include "stdafx.h" #include "IIRO8.h" #include "IIRO8Dlg.h" #include "ACCES32.h" #define MyKey "Software\\PCIFIND\\NTioPCI\\Parameters" #define InsCR(x) x += 0x0d; x += 0x0a; TPCI_COMMON_CONFIG buf[64]; bool RunFlag; unsigned long Address; #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CIIRO8Dlg dialog CIIRO8Dlg::CIIRO8Dlg(CWnd* pParent /*=NULL*/) : CDialog(CIIRO8Dlg::IDD, pParent) { //{{AFX_DATA_INIT(CIIRO8Dlg) m_StatusEdit = _T(""); m_CardName = _T(""); m_IsaEdit = _T("300"); m_BaseStatic = _T(""); m_RelayOutput = _T("00000000"); m_RelayReadback = _T("00000000"); m_OptoInput = _T("00000000"); //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CIIRO8Dlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CIIRO8Dlg) DDX_Control(pDX, IDC_ISA_STATIC, m_IsaStatic); DDX_Control(pDX, IDC_STATUS, m_StatusControl); DDX_Control(pDX, IDC_ISA_EDIT, m_IsaEditCtrl); DDX_Control(pDX, IDOK, m_TimerButton); DDX_Text(pDX, IDC_STATUS, m_StatusEdit); DDX_Text(pDX, IDC_CARD_NAME, m_CardName); DDX_Text(pDX, IDC_ISA_EDIT, m_IsaEdit); DDX_Text(pDX, IDC_BASESTATIC, m_BaseStatic); DDX_Text(pDX, IDC_OUTPUTA, m_RelayOutput); DDX_Text(pDX, IDC_INPUTA, m_RelayReadback); DDX_Text(pDX, IDC_INPUTB, m_OptoInput); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CIIRO8Dlg, CDialog) //{{AFX_MSG_MAP(CIIRO8Dlg) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDCANCEL, OnExitButton) ON_BN_CLICKED(IDOK, OnBeginButton) ON_WM_TIMER() ON_WM_SHOWWINDOW() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CIIRO8Dlg message handlers BOOL CIIRO8Dlg::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 CIIRO8Dlg::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 CIIRO8Dlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } void CIIRO8Dlg::OnExitButton() { exit(0); } void CIIRO8Dlg::FindCards(void) { int i; bool found; HKEY Key; unsigned long DataType, DataLength; long Num; char AddStr[255]; found = false; RegOpenKeyEx(HKEY_LOCAL_MACHINE, MyKey, 0, KEY_READ, &Key); DataLength = sizeof(Num); RegQueryValueEx(Key, "NumDevices", NULL, &DataType, (PUCHAR)&Num, &DataLength); RunFlag = true; if (Num > 0) { DataLength = Num * sizeof(TPCI_COMMON_CONFIG); RegQueryValueEx(Key, "PCICommonConfig", NULL, &DataType, (PUCHAR)buf, &DataLength); } for (i=0; i0) + 0x30); m_RelayOutput = msg; for (j=0; j<8; j++) msg[7-j] = (((value[1] & (1 << j))>0) + 0x30); m_RelayReadback = msg; for (j=0; j<8; j++) msg[7-j] = (((value[2] & (1 << j))>0) + 0x30); m_OptoInput = msg; UpdateData(false); CDialog::OnTimer(nIDEvent); } void CIIRO8Dlg::OnShowWindow(BOOL bShow, UINT nStatus) { CDialog::OnShowWindow(bShow, nStatus); InsCR(m_StatusEdit); FindCards(); }