473,799 Members | 3,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

USB communications using StreamReader and StreamWriter

2 New Member
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
Expand|Select|Wrap|Line Numbers
  1.  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
Feb 15 '12 #1
2 1099
PsychoCoder
465 Recognized Expert Moderator Contributor
Show us the code where you're declaring the Win32 API GetStreamFromGu id and how you're populating m
Feb 15 '12 #2
shalami
2 New Member
Expand|Select|Wrap|Line Numbers
  1. namespace WindowsFormsApplication6
  2. {
  3.     public partial class Form1 : Form
  4.     {
  5.  
  6.         public Form1()
  7.         {
  8.             InitializeComponent();
  9.         }
  10.  
  11.         private void Form1_Load(object sender, EventArgs e)
  12.         {
  13.         }
  14.         class WinAPIWrapper
  15.         {
  16.             // Use DllImport to import the Win32 GetFocus function.
  17.             //[STAThread]
  18.             //[DllImport("User32.dll")]
  19.             [DllImport("setupapi.dll", CharSet = CharSet.Auto,SetLastError = true)]
  20.             //[DllImport("Kernel32.dll")]
  21.             //[DllImport("gdi32.dll")]
  22.  
  23.             public static extern string GetStreamFromGuid(Guid b,string a);
  24.  
  25.         }
  26.         /*[DllImport("setupapi.dll")]
  27.         public static Guid m = new Guid();//"53f56307-b6bf-11d0-94f2-00a0c91efb8b");
  28.         StreamReader fPipein = new StreamReader(WinAPIWrapper.GetStreamFromGuid(m, @"\PIPE00"));
  29.     }
  30. }
thanks
Feb 15 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2436
by: Joecx | last post by:
Using vb.net, I am using Streamreader to read a text file and searching for a line to delete, the I close the file and open it as a streamwriter so I can put the new file back to disk without the line that I deleted. Can someone tell me how I can do this without having to close the file first before switching to streamwriter, because closing the file allows someone else to grab the file before I put the new information back. Thanks if any...
5
6346
by: Lyle | last post by:
How do get a line control on the end of a line using the streamwriter.writeline (not carriage line control)? How do you get the following command to print a quote in the file? I have tried using double quotes as shown below but this is not working. outfilew.WriteLine(""@@BATCHLOAD glrtmt.p"") THANKS! From http://www.developmentnow.com/g/38_2005_8_0_22_0/dotnet-languages-vb.htm
1
1455
by: Stephen | last post by:
Hi, I am reading a file (c:\address.txt) using streamreader and I want to make changes to a line in the file and save it. will there be a locking issue if I read and write to the samefile simultaneously? Thanks, Stephen
1
2231
by: JM | last post by:
Hi, I have been trying to read a file, using "StreamReader" to pass the info to an string that is: ....dim stream as new FileStream(file,...) dim sr as new StreamReader(stream) dim data as string = sr.ReadToEnd... My problem is that in the file (is a text file) there is some data like:
5
7606
by: jkristia | last post by:
StreamReader throws an exception if I attempt to open a .csv file which is also opened by Excel. I checked this list and found what I though was the solution, first open the file stream in read only, But unfortunately that doesn't work either Stream s = File.OpenRead(filename); using (StreamReader sr = new StreamReader(s)) { }
2
3113
by: Thelonious Monk | last post by:
I have a problem where some data is being eliminated. The problem is that the data contains signed numeric fields (the low-order byte of a negative number uses the first 4 bits as a sign and the last 4 bits as the low-order digit. This produces byte values higher than X'7F'. To be more specific these values are hexadecimal X'B0' through X'B9'. It appears the program is eliminating any byte values greater than X'7F', thus shortening...
5
6883
by: Rob | last post by:
Hi, I have a VB.Net application that parses an HTML file. This file was an MS Word document that was saved as web page. My application removes all unnecessary code generated by MS Word and does some custom formatting needed by my client. I use a StreamReader to read in the file...regular expressions to parse and clean up the file...and a StreamWriter to write the new file. On some HTML files that I parse, I get this character "á"...
1
1930
by: xitij9 | last post by:
Hi, I am importing a .csv file using StreamReader. I can not use Jet Engine as I cannot install it on client. I am reading it line by line and then split the line with comma and get the array. (Is there any more efficient way then this ?). using (StreamReader sr = new StreamReader(_fileName)) { string line; while ((line = sr.ReadLine()) != null) ...
7
7777
by: =?Utf-8?B?TWFuanJlZSBHYXJn?= | last post by:
Hi, I am using StreamReader to read an ASCII file that contains blank lines. How can I omit reading blank lines? I tried somting like... FileStream inFile = new FileStream("c:\HTAC10A.PRN",FileMode.Open); StreamReader inreader = new StreamReader(inFile); string line = inreader.ReadLine();
3
5237
by: stumorgan | last post by:
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. The StreamReader is working beautifully, but the StreamWriter isn't. If I convert the StreamWriter.BaseStream back to a FileStream and use its SafeFileHandle in the Windows API WriteFile...
0
10257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.