// PCIDADlg.cpp : implementation file // #include "stdafx.h" #include "PCIDA.h" #include "PCIDADlg.h" #include "ACCES32.h" #include #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #define InsCR(x) x += 0x0d; x += 0x0a; #define MyKey "Software\\PCIFIND\\NTioPCI\\Parameters" bool RunFlag, Testing; unsigned long Base, XValue; unsigned long Value; TPCI_COMMON_CONFIG buf[64]; unsigned long WhichAddress[64], WhichEPROMAddress[64]; int NumChannels[64]; ///////////////////////////////////////////////////////////////////////////// // CPCIDADlg dialog CPCIDADlg::CPCIDADlg(CWnd* pParent /*=NULL*/) : CDialog(CPCIDADlg::IDD, pParent) { //{{AFX_DATA_INIT(CPCIDADlg) m_StatusEdit = _T(""); //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CPCIDADlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPCIDADlg) DDX_Control(pDX, IDOK, m_StartButton); DDX_Control(pDX, IDC_EDIT1, m_StatusControl); DDX_Control(pDX, IDC_COMBO2, m_ChannelsComboControl); DDX_Control(pDX, IDC_COMBO1, m_CardComboControl); DDX_Text(pDX, IDC_EDIT1, m_StatusEdit); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CPCIDADlg, CDialog) //{{AFX_MSG_MAP(CPCIDADlg) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDCANCEL, OnExit) ON_WM_SHOWWINDOW() ON_BN_CLICKED(IDOK, OnStartClick) ON_WM_TIMER() ON_CBN_SELCHANGE(IDC_COMBO1, OnSelChangeCardCombo) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPCIDADlg message handlers BOOL CPCIDADlg::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 CPCIDADlg::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 CPCIDADlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } void CPCIDADlg::OnExit() { exit(0); } void CPCIDADlg::OnShowWindow(BOOL bShow, UINT nStatus) { CDialog::OnShowWindow(bShow, nStatus); FindCards(); } void CPCIDADlg::FindCards(void) { int i, n = 0; HKEY Key; unsigned long DataType, DataLength; long Num =0; char AddStr[255]; RegOpenKeyEx(HKEY_LOCAL_MACHINE, MyKey, 0, KEY_ALL_ACCESS, &Key); DataLength = sizeof(Num); RegQueryValueEx(Key, "NumDevices", NULL, &DataType, (PUCHAR)&Num, &DataLength); if (Num > 0) { DataLength = Num * sizeof(TPCI_COMMON_CONFIG); RegQueryValueEx(Key, "PCICommonConfig", NULL, &DataType, (PUCHAR)buf, &DataLength); RunFlag = true; } for (i=0; i