Mohl by tu prosím být někdo tak strašně moc hodný a ukázal mi jak přepsat tenhle sample kód z C++ do C#? Vůbec to nemůžu dát dohromady. Byl bych mu strašlivě zauzlovaný...
1.) Open PARINTF port
#include “parintfsdk.h”
HANDLE hPIF;
hDIO = CreateFile( _T("PIF1:"),
GENERIC_WRITE, 0,
NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL );
if( hDIO == INVALID_HANDLE_VALUE )
{
MessageBox( NULL, TEXT("WinMain():
CreateFile() failed"),
TEXT("Err! – PIF-Test"),
MB_OK | MB_ICONEXCLAMATION);
return(FALSE);
}
2.) Write data to port without Address
unsigned char data[3] = { 0x1, 0x2, 0x3 };
DWORD dwBytesWrite = 1;
WriteFile( hDIO, data, 3,
&dwBytesWrite, NULL );
if( dwBytesWrite != 3 )
{
// Error
}
2.) Read data from port without Address
unsigned char data[3] = { 0x1, 0x2, 0x3 };
DWORD dwRead;
ReadFile( hDIO, data, 3, &dwRead, NULL );
if( dwRead != 3 )
{
// Error
}
3.) Write address/data to port
PARINTFRW cData;
DWORD dwBytesReturend;
cData.chAddress = 0x20;
if( !DeviceIoControl( m_hPIF,
IOCTL_PARINTF_WRITE,
&cData, sizeof(cData), NULL, 0,
&dwBytesReturend, NULL ) )
{
DWORD dwLastError = GetLastError();
} |