|
I deal with packets to byte streams quite frequently in client/server applications. Packets are essentially data structures with an assortment of binary and ascii or whatever formatted data. Here are a couple functions you could use, and polymorhisize as you need:
<br />
public int Encode( int i32Value, ref byte[] pdu, int off )<br />
{<br />
byte[] byte32Int = new byte[ cBytesPerWord32 ];<br />
int netValue = System.Net.IPAddress.HostToNetworkOrder( i32Value );<br />
byte32Int = BitConverter.GetBytes( netValue );<br />
Array.Copy( byte32Int, 0, pdu, off, cBytesPerWord32 );<br />
return cBytesPerWord32;<br />
}<br />
<br />
public int Decode( ref byte[] pdu, int off, ref uint u32Value )<br />
{<br />
uint netValue = BitConverter.ToUInt32( pdu, off );<br />
u32Value = (uint)System.Net.IPAddress.NetworkToHostOrder( (int) netValue );<br />
return cBytesPerWord32;<br />
}<br />
Although the function above only deals with 32-bit uint's you can imagine how easy it is to add support for 16-bit and 64-bit integers/unsigned integers. Strings are variable length in most cases otherwise a simple Array.Copy() would suffice. So if you have to pass strings, at a minimum you'll be best served with a length byte and quite possible some sort of a type or tag byte - especialy if you have lots of string elements. That way you can handle strings in any order.
Good luck
Mike Luster
CTI/IVR/Telephony SME
|
|
|
|
|
HI,
Can anyone tell me how to access remote registry which is in different domain?...I am getting UnauthurizedAccessException
|
|
|
|
|
You would have to establish a trust between the local and remote domains or impersonate a user from the other domain.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
thanks for the reply........but can u say me how can i do that???....cos i am new to c#...thanks in advance
|
|
|
|
|
It is more an administration task than a programming one. One thing you could do, though, if you have access to the remote server and can install a web service on it, you could write a web service that gives access to the local registry.
Btw, why do you want to have access to the remote registry? Generally, it is not a good idea to open the registry to the outside world.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Actually my project is about retrieving softwares and hardware information from each system(from registry) in a lan...I used RegistryKey class to do that...for remote system,i used OpenRemoteBaseKey method...All works for me within a domain...If i do that for a system in another domain,then UnauthorizedAccessException is coming...Can u help me in this situation
|
|
|
|
|
You have 2 choices:
1- Make the 2 domains trust each other, and have an account that has admin privileges in both, if it is possible.
2- Run your program in each domains, separately.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
ok Michel.......very much thanks.......I will try the first one.....Do tell me if we have any other way...........
|
|
|
|
|
I want to disable some windows functions when my form loads. Would I just set the form to FixedDialog when you load it?
I want to disable the Alt-Tab function and the ctrl+alt+del functions so they cannot be used. How would you do this?
In the end we're all just the same
|
|
|
|
|
|
Actually all I want to do is disable the start button key on the keyboard... so you cant press it and bring up the start menu. What would making my main form afixed dialog do?
In the end we're all just the same
|
|
|
|
|
I have a context menu and I was wondering was there a way of getting it to look like the windows start menu. I want just to add a panel on the side of the menu which looks like the one in windows Start Menu eg the Windoiws 98 Start menu says Windows 98 down the side of it. This is what I want
In the end we're all just the same
|
|
|
|
|
how to display data in treeview from access database ,, and to add child to tree and database
|
|
|
|
|
|
Hi,i have the following problem:
My computer is connected to a remote server using a socket.The server sends me a movie file andi want to play that file on my computer as it comes through the socket.
I can't use the Video class because this class only plays files saved on the harddisk.
Pls Help
|
|
|
|
|
hi
every body
i work in c# 2005 and have a question
some of my friend that work in vb show something beautful in vb that is My
i am a new user of c#2005 and work on c# 2003 before that so don't know anything about my .
now i want to know is there any equal to my in c#2005
Regards Amir Jalaly
|
|
|
|
|
|
|
Amir Jalaly wrote: some of my friend that work in vb show something beautful in vb that is My
The My namespace is just a façade onto existing .NET Framework classes. There is nothing new of "beautiful" about it, in my opinion. It is just an extension of the over simplification of things in VB.NET that leads to a group of Me, My, Fisher Price developers.
Façade classes, in my opinion, should be written in house for the purposes required by the application as they dictate how an application interacts with other classes. If you need to interact with framework classes in the same way on multiple occasions then great! Write a façade class for it.
If the framework comes with façade classes built in then you are losing control somewhat because then the framework is dictating how you interact with other framework classes. They become black boxes that don't encourage the devloper to actually know what is goind on underneath and leads to problems when things go wrong.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
As I understand it you should be able to include the vb classes in a C# application and use My as much as you want.
|
|
|
|
|
this is not a class .
as i read in msdn my is a special key word for vb2005
Regards Amir Jalaly
|
|
|
|
|
Amir Jalaly wrote: ForumC#
Subject:Re: what c# has equal to my in vb2005?
Sender:Amir Jalaly
Date:1:42 9 Mar '06
this is not a class .
Of course it's a class. .NET 101: EVERYTHING IS A CLASS
Add a reference to the Visual Basic dll in your project and then add the Microsoft.VisualBasic namespaces to your application that you need. You'll find all the My objects in there somewhere. For example, Computer and Audio are in the Devices namespace and User is in the ApplicationServices namespace.
|
|
|
|
|
First: My Internet speed was very slow that's y i sent problem more than one time.
Hello,
Thanks a lot for every brother, dear i want to do this in Web Application not in Windows Application so please send me some code how can i add textboxes in controls and use later on..
THE QUESTION WAS "I used a number of Textboxes in Web Application using C#, now i want to access all these but i don't want to write name of each textbox i just want to use an ARRAY to assign values (Or Access these textboxes), I saw this somewhere in Visual Basic 6.0 but i don't know how can i do that in Visual Studio 2003 please tell me some solution for this to avoid write the names of all these ???????????????"
Regards,
AbuBakar
|
|
|
|
|
You're probably talking about the Index feature in VB6.
This isn't available in .Net.
You could however tag your textboxes (.Tag = "Somename")
And then with a loop through all Controls check for the tag and work like that.
This still means you can't do this.
textBox[1].Text = "Something";<br />
textBox[2].Text = "Something Else";
But you could do:
foreach (Control ctrl in Controls)<br />
{<br />
if (ctrl.Tag.Equals("Somename"))<br />
{<br />
ctrl.Text = "Something";<br />
}<br />
}
|
|
|
|
|
hi,
I wanted to know if i get drives using the function "System.Environment.GetLogicalDrives()",then is there any methods which can tell which drive is what?Say i wanted to know whether "D:" is CDROM or the hard disk drive.
Can anybody help me?
Thanx in advance.
Nitin_ap
nitin_ap
|
|
|
|