发表于:2003-06-26 17:07:00
                
                楼主
             
            
            
                我用基于对话框的MFC AppWizard(exe)生成了项目,添加了头文件和包含的动态连接
以下是添家的内容,只要实现最基本的由按纽触发向研华PCL724 A口发送一个字节,调试通过,执行的时候没有反映,麻烦各位老师指点:
#include "driver.h"
...
static      PT_DioWritePortByte ptDioWritePortByte; // DioWritePortByte table
LRESULT     ErrCde;                   // return error code
LONG        DriverHandle = (LONG)NULL; 
...
int CTestDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	ErrCde = DRV_DeviceOpen(0,&DriverHandle);
	if (CDialog::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	
	return 0;
}
...
void CTestDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
	ptDioWritePortByte.port=1;
	ptDioWritePortByte.mask=0xff;
	ptDioWritePortByte.state=255;
	ErrCde = DRV_DioWritePortByte(DriverHandle,&ptDioWritePortByte);
}
...
BOOL CTestDlg::DestroyWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	
	ErrCde = DRV_DeviceClose(&DriverHandle);
	return CDialog::DestroyWindow();
}