You can make this code a little bit more friendly by updating the header file to prevent name mangling and add a couple method definitions:
#ifndef _DIO_H
#define _DIO_H
#ifdef __cplusplus
extern "C"
{
#endif
BOOL GetMask(HANDLE hDioPort, DWORD *pdwMask);
BOOL SetMask(HANDLE hDioPort, DWORD dwMask);
BOOL ReadDio(HANDLE hDioPort, DWORD *pdwDio);
BOOL WriteDio(HANDLE hDioPort, DWORD dwDio);
BOOL SetDirection(HANDLE hDioPort, DWORD dwDir);
BOOL GetDirection(HANDLE hDioPort, DWORD *pdwDir);
DWORD GetUserDword(const char *szStr);
HANDLE OpenDIO();
BOOL CloseDIO(HANDLE hDioPort);
#ifdef __cplusplus
}
#endif
#endif // _DIO_H
And then add these to the implementation file:
HANDLE OpenDIO()
{
return CreateFile(_T("DIO1:"), GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, NULL);
}
BOOL CloseDIO(HANDLE hDioPort)
{
return CloseHandle(hDioPort);
}