|
For standard file or memory streams you could determine the length of the stream and in a loop read until that many bytes are read. However, seek methods are not supported for the type of stream returned from GetResponseStream. I'm not saying my way is the only way, but when you do get to a compiler, I think you'll find it works
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
Thanks Tom,
My confusion is when the Read function is call the second time. Will you lose the info that was already in buf? or is going to attached it at the end of the buf instead of buf[0]?
Again, thanks!
Al
|
|
|
|
|
Albert Pascual wrote:
My confusion is when the Read function is call the second time. Will you lose the info that was already in buf? or is going to attached it at the end of the buf instead of buf[0]?
Yes, I'm writing into the same buf byte array each time through the loop. That's why the WriteLine is in the loop; to print the information on the screen before it gets overwritten with the next block of read data.
Albert Pascual wrote:
Again, thanks!
No problem
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
My fault, my fault!
I always return the big buffer!!
what a mistake! I am sorry I actually didn't read past the Read() function!
My apologies for wasting your time
Al
|
|
|
|
|
No worries, mate
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
It works.Thanck you very much Tom!
|
|
|
|
|
You're very welcome.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
Hi,
I'm having an issue wrapping a particular function from an API. The function looks like:
bool GetPacket(LPADAPTER ad, LPPACKET pack, bool s)
LPADAPTER and LPPACKET are pointers to structures. What I did in C#:
[DllImport("Packet.dll")]
internal extern static bool GetPacket (ref ADAPTER a, ref PACKET p, bool s);
I allways get false in return. I think its a problem with the pointer to structure, but I'm not sure. Any ideas???
The structures have both 4 fields (2 pointers (IntPtr) and 2 uints).
Thanks,
G
|
|
|
|
|
What's the declaration on Packet.dll for that function?
You always can add a breakpoint an debug unmanaged code!
Al
|
|
|
|
|
The declaration in the API dll is:
____________________________________________________________________
BOOLEAN PacketReceivePacket(LPADAPTER a, LPPACKET p, bool S);
// LPADAPTER is a pointer to an ADAPTER struct
// LPPACKET is a pointer to a PACKET struct
____________________________________________________________________
public struct ADAPTER{ IntPtr handle;
uint SymbolicLink;
uint NumWrites;
IntPtr ReadEvent;}
public struct PACKET{ IntPtr hEvent;
public IntPtr Buffer;
public uint Length;
public IntPtr Next;
public uint BytesReceived;
bool IoComplete;}
____________________________________________________________________
This is what i do in C#:
____________________________________________________________________
//initialize adapter and packet, etc. This works fine (functions return true)
//then:
bool b = false;
IntPtr pp = PacketAPI.PacketAllocatePacket();
PacketAPI.PACKET P =
(PacketAPI.PACKET)Marshal.PtrToStructure(pp,typeof(PacketAPI.PACKET));
byte [] BB = new byte[256000];
IntPtr ptBuf = Marshal.UnsafeAddrOfPinnedArrayElement(BB,0);
P.Buffer = Marshal.UnsafeAddrOfPinnedArrayElement(BB,0);
P.Length = 256000;
b = PacketAPI.PacketReceivePacket(ref A,ref P,false); //Always false
____________________________________________________________________
Thanks for your help,
G
|
|
|
|
|
I am trying to implement a text editable, autocomplete combobox by deriving from ComboBox class and overiding OnKeyPress().
However I can't fix this bug, whenever text is typed into combobox, the mouse disappears, and doesn't show even when the mouse is moved. In fact, it's like the mouse is hiding behind the form window, because whenever it enters the form, the pointer disappears.
Anyone, please help, thanks...
lester
|
|
|
|
|
This may sound very elementary to some. Please forgive me for the ****STUPID**** question.
In VB CHAR () returns the ASCII value. Is there anything similiar to CHAR( ) in c-sharp? Actually I would like test for STX and ETX in a string.
Thank you.
|
|
|
|
|
I know that in C++ a char IS the ASCII value.
(2b || !2b)
|
|
|
|
|
I maybe way off here, and I bet James or someone else will set me straight on this, but here is my guess...
private string TheWord;
private int TheNumber;
TheWord = "Hello Abdul";
TheNumber = (int)TheWord;
MessageBox.Show(TheNumber.ToString());
HTH
Nick Parker
|
|
|
|
|
What is STX and ETX? Are they strings you are looking for or a certain property?
You can get the character code by looking at the character stored in each character, which you can get by using the indexer on a string (string foo; foo[x] ). Then you can convert that character to its unicode value.
string f = "foo";<br />
char c = f[0];
short s = Convert.ToInt16(c);
If memory serves correctly the ASCII set is a subset of Unicode, so an ASCII value will map to the same value in unicode.
HTH,
James
Simplicity Rules!
|
|
|
|
|
STX is the start of text and ETX is end of text and is represented by decimal equivalent of 2 and 3 respectively (like in your case 'f' is represented by decimal value 102).
I have not tried your example yet but I think it should work. Thanks mate.
Abdul.
|
|
|
|
|
i try to transport the msflexgrid control that is very popular in visual basic6.0 development environment to vs.net in windows server2000 environment!
but i try for a whole day,just in vain!hehe!
in vs.net disk1\extra folder,it said i just only need to load the license key register info for the msflexgrid into registery!but not work!
anyone can help me?or we can discuss it?
i will send the msflxgrd.ocx and license key!
|
|
|
|
|
|
hi!
i am a programmer,but i am new to programmer forums!
can everyone tell me other famous and large forums related to programming??
thanks!!
|
|
|
|
|
You could try the VC++ forums if you are a VC++ guy. This is the C# forum.
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
sorry,i mean other websites' forums that is famous and popular and hot other than the forums of codeproject.com
|
|
|
|
|
Oh!
Then try http://codeguru.com
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
except codeguru.com,codeproject.com,tek-tips.com!
are there any more that is attracting more and more people??thanks!
|
|
|
|
|
This is an odd request. What you're looking for ( flexgrid ) is an odd request, you're unlikely to get an answer. However, codeguru & CP are IMO without doubt the most populated sites on the web. In any case, if you can't figure out www.google.com, you probably shouldn't be programming.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Well said Christian. Coming in here and asking about other forums is tantamount to going into a restaurant and asking the chef there to give you the names of his competitors.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|