If you need support for devices like "com1:" or "lpt1:", then call CreateFile (a Win32 SDK function) yourself then use the FileStream constructors that take an OS handle as an IntPtr.
Instead of mixing and matching Win32 and .Net streams, you could use only Win32SDK functions, using WriteFile and ReadFile functions.
To open it use CreateFile with the file name of LPT1 to get a handle fot the WriteFile/ReadFile() calls.
HANDLE CreateFile(
LPCTSTR lpFileName, // file name
DWORD dwDesiredAccess, // access mode
DWORD dwShareMode, // share mode
LPSECURITY_ATTRIBUTES lpSecurityAttributes, // SD
DWORD dwCreationDisposition, // how to create
DWORD dwFlagsAndAttributes, // file attributes
HANDLE hTemplateFile // handle to template file
);
Hope this helps.
Sincerely,
Buzzby
Main Topics
Browse All Topics





by: ShaunWildePosted on 2003-01-02 at 09:35:27ID: 7656707
you should really think of using a more appropriate language eg C or C++ and or using the windows API - I don't think C# is capable of accessing hardware in the manner you mention using the framework.