|
I send you the whole code on your email address.
Plz collect it from there.
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
Here's how.
public struct MyStruct
{
public int x;
public int y;
public float z;
}
IntPtr p;
MyStruct s;
int size;
byte[] buffer;
s = new MyStruct();
s.x = 1;
s.y = 2;
s.z = 3.0f;
size = sizeof( typeof( MyStruct ) );
p = Marshal.AllocHGlobal( size );
Marshal.PtrToStructure( s, p, true );
buffer = new byte[ size ];
Marshal.Copy( p, buffer, 0, size );
Marshal.FreeHGlobal( p );
I hope this helps.
Deus caritas est
|
|
|
|
|
Sorry, the Marshal.PtrToStructure should be Marshal.StructureToPtr .
Deus caritas est
|
|
|
|
|
Greate. Good.
I will help me throught out my project.
Thanx Andy.
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
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
|
|
|
|