📄 gpiodlg.cpp
字号:
// GPIODlg.cpp : implementation file
//
#include "stdafx.h"
#include "GPIO.h"
#include "GPIODlg.h"
#include "GPIO2.H"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGPIODlg dialog
HANDLE hFile =INVALID_HANDLE_VALUE;
CGPIODlg::CGPIODlg(CWnd* pParent /*=NULL*/)
: CDialog(CGPIODlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CGPIODlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CGPIODlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGPIODlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGPIODlg, CDialog)
//{{AFX_MSG_MAP(CGPIODlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGPIODlg message handlers
BOOL CGPIODlg::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
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CGPIODlg::OnButton1()
{
// TODO: Add your control notification handler code here
// BOOL ret;
BYTE pinnum=10;
hFile=CreateFile(TEXT("SPL1:"),GENERIC_READ | GENERIC_WRITE,0,
NULL,OPEN_EXISTING,0,0);
if(hFile==INVALID_HANDLE_VALUE)
{
MessageBox(_T("can't open!"));
return;
}
else
{
MessageBox(_T(" open successful!"));
}
}
void CGPIODlg::OnButton2()
{
// TODO: Add your control notification handler code here
if(hFile!=INVALID_HANDLE_VALUE)
{
CloseHandle(hFile);
hFile=INVALID_HANDLE_VALUE;
}
}
void CGPIODlg::OnButton3()
{
// TODO: Add your control notification handler code here
BOOL ret;
BYTE y;
ret=::DeviceIoControl(hFile,1,&y,1,NULL,0,NULL,NULL);
}
void CGPIODlg::OnButton4()
{
// TODO: Add your control notification handler code here
BYTE y;
ReadFile(hFile,&y,1,NULL,NULL);
}
void CGPIODlg::OnButton5()
{
// TODO: Add your control notification handler code here
BYTE y;
WriteFile(hFile,&y,1,NULL,NULL);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -