USB communications using StreamReader and StreamWriter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shalami
    New Member
    • Feb 2012
    • 2

    USB communications using StreamReader and StreamWriter

    I'm doing some USB communications in C# and am running into a minor
    annoyance. I'm using the Windows API CreateFile function to get a
    SafeFileHandle, which I then stuff into a FileStream and from there
    into StreamReader and StreamWriter objects.
    i do this code for streamreader
    Code:
     StreamReader fPipein = new StreamReader(WinAPIWrapper.GetStreamFromGuid(m, @"\PIPE00"));
    but visual-studio-c# show this error to me
    Unable to find an entry point named 'GetStreamFromG uid' in DLL 'User32.dll'.
    Unable to find an entry point named 'GetStreamFromG uid' in DLL 'User32.dll'.

    and also for chenging to setupapi.dll

    Unable to find an entry point named 'GetStreamFromG uid' in DLL 'setupapi.dll'.

    i dont know what should i do... for a safe handle to access usb for reading ang writing

    thanks
    Last edited by PsychoCoder; Feb 15 '12, 08:06 AM. Reason: Added code tags
  • PsychoCoder
    Recognized Expert Contributor
    • Jul 2010
    • 465

    #2
    Show us the code where you're declaring the Win32 API GetStreamFromGu id and how you're populating m

    Comment

    • shalami
      New Member
      • Feb 2012
      • 2

      #3
      Code:
      namespace WindowsFormsApplication6
      {
          public partial class Form1 : Form
          {
        
              public Form1()
              {
                  InitializeComponent();
              }
      
              private void Form1_Load(object sender, EventArgs e)
              {
              }
              class WinAPIWrapper
              {
                  // Use DllImport to import the Win32 GetFocus function.
                  //[STAThread]
                  //[DllImport("User32.dll")]
                  [DllImport("setupapi.dll", CharSet = CharSet.Auto,SetLastError = true)]
                  //[DllImport("Kernel32.dll")]
                  //[DllImport("gdi32.dll")]
                  
                  public static extern string GetStreamFromGuid(Guid b,string a);
                  
              }
              /*[DllImport("setupapi.dll")]
              public static Guid m = new Guid();//"53f56307-b6bf-11d0-94f2-00a0c91efb8b");
              StreamReader fPipein = new StreamReader(WinAPIWrapper.GetStreamFromGuid(m, @"\PIPE00"));
          }
      }
      thanks
      Last edited by PsychoCoder; Feb 15 '12, 06:48 PM. Reason: Added code tags

      Comment

      Working...