|
You can declare an array of bytes like this:
byte[] <code>buffer</code> = new byte[1];
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Thanks, but I am not sure that's what I need.
In C++, my structure looks as follows:
struct sample_
{
unsigned short f1;
long f2;
unsigned char filler[1000];
}; // total 1006
I declared it in C# as follows:
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi, Pack=1)]
public class sample_
{
public ushort f1;
public int f2;
public byte[] arr=new byte[1000];
}
But it's not good because the size should 1006, and it is actually 10 (2+4+4).
sample_ mySample = new sample_();
Console.WriteLine ("sizeof={0}", Marshal.SizeOf(mySample));
Is there a way I can declare the array without new? Or do I have to declare 1000 byte fillers?
|
|
|
|
|
Packing size is done as follows:
[StructLayout(LayoutKind.Sequential, Pack=1)]
public struct WhoCares
{
public int x;
public int y;
}
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I got the same problem.at last ,I found a question that the size of the struct is very complex as we thought.But there is a way to read the blok of memory that stored as struct type.Maybe we can disguss it together.
|
|
|
|
|
Not until you start your own question as a new thread. I'm not responding to someone who thinks they can just hyjack someone elses 4 year old thread and I'l magically know what they're talking about.
|
|
|
|
|
Hi. I have finished my app and now would like to have an installer which would copy the files to a dir chosen by the user, register my file type and an icon in the system and also an uninstaller which would unregister and delete the dir.
Are there any components for that or do I have to do it myself?
|
|
|
|
|
|
Any links on how to use this project?
And how do I register my own filetype?
Thanks for the answer!
|
|
|
|
|
There is a good MSDN Help article on Deploying Applications...
Topic ID: _328642
Topic Title: Deploying Applications
URL: ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vsintro7/html/vbconDeployingSolution.htm
It is a good place to start....
|
|
|
|
|
Ok, I managed to make an installer
But how can I add something to the register during install and remove it during uninstall?
|
|
|
|
|
I have a code that works: it registers my files with the file system. it's an exe but it can well be a method in a properties window. Hovewer, I'd like to add it during install. Can anybody tell me how?
|
|
|
|
|
How do I convert data contained in an arry from
1.hexa to decimal
2.ascii to characters
Prakash Khatri
|
|
|
|
|
Your request is somewhat vague, so I shall do my best to answer. I've given my assumtions of what I think you mean.
What format is the data in the array stored as? I'm going to assume string.
1. I'm going to assume you mean a hexadecimal string to an integer. You can use int.Parse(myString, NumberStyles.HexNumber); . If you need this back as a string you can do string.Format("{0}",int.Parse(myString, NumberStyles.HexNumber));
2. This makes no real sense. Do you mean you have an array of ASCII characters which you want to convert to a string?
System.Text.ASCIIEncoding asciiEnc = new System.Text.ASCIIEncoding();
string result = asciiEnc.GetString(myByteArray);
Does this help?
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
I don't respond off the forum. Any help that I give here is for everyone.
Prakash Khatri wrote:
thanks for the reply.but you dint understand whta i
meant.firstly
1.im reading 2 bytes of a tag intoa bye array.then im
converting it to a string n printing it.the thing is
that the value in the string is a decimal value.i want
its hexa equivalent.any ideas?
2.im reading in data into a byte array.the data is in
being output in the ASCII form,which im guessin is
decimal!?the thing is i want it to output the ASCII
equivalent..as in 97=a..so i tried reading into a char
array as then it'd be output in that way.but even thts
not working.it doesnt give me an output.it jus stays
blank..lolz!any ideas here as well?
3.Do you know off any way to create a table-like
format in csharp w rows n columns etc.?
could you pleasr reply ur response to
xxx.xxx@xxx.com as well
Number 1. See String.Format()[^]. The code you need is probably:
string.Format("{0:x}",value);
Number 2: If the data is being output as ASCII then it is ASCII, I don't know what you mean by decimal in this context. ASCII is already a particular encoding of characters. UTF-7 and UTF-8 are other forms. If the ASCII represents a sequence of number 0-9 then you can convert the byte array to a string then run int.Parse(myString) on it to convert the string to an integer.
Number 3: Use a DataSet.
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
I want to be able to save the current screen and somehow store the result in an Image or Bitmap object. How can I do this?
|
|
|
|
|
Have a look here[^].
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
This was exactly what I wanted (and even more - my program creates a thumbnail picture now!)!
Thanks a lot Polis!
|
|
|
|
|
Ur welcome
Glad I could help
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
hi
i need to round off an integer to the nearest 100
probably a very simple solution but its wreckin me head
any takers?
Tanx
Katie
|
|
|
|
|
That's not rounded - it's truncated!
-----------------------------
Get trial copy of comment generating tool CommentMakerPro, a collection of convenience and productivity tools for Microsoft Visual Studio .NET FeinStuff, and std::string and std::string containers viewer FeinEvaluatorPro at www.FeinSoftware.com
|
|
|
|
|
System.Math.Round(The number of the digits it will be to the nearset to );.
|
|
|
|
|
I'm trying to write a toolbar using this tutorial:
"http://www.codeproject.com/csharp/dotnetbandobjects.asp"
by the tutorial I am trying to sign the assembly with a strong name using this line:
[assembly: AssemblyKeyFile(@"..\..\..\BandObjects.snk")]
but I keep on getting the error:
duplicate 'AssemblyKeyFile' attribute.
I tried to continue without that line and using only regasm without the gacutil (because of a post someone added in board of this tutorial),
but of course it doesn't work...
can anyone help me with this ???
Thanks!
|
|
|
|
|
Hi - any help with this would be greatly appreicated - it has already had me
confused for a good few hours!
I am using Visual Studio 2003 and the .NET framework 1.1.
I have a C# Windows Service, with my own class extending from ServiceBase in
the normal fashion. The service starts a remoting object (WKO and
singleton) which many clients can then make calls on. Clients may also
register with events on the server such that the server will inform clients
when certain actions occur.
This all works fine and clients are appropriately notified when the server
fires the events.
However, I would like the clients to also be informed when the service is
stopping - and so I thought that firing an event in the service's overridden
OnStop() function would be ideal for this. I can see that the multicast
delegate on the server has the delegates to call upon so it seems the
clients have successfully registered their interest in the service shutting
down. I can prove this by firing the event at any time and all works well.
However, the strange behaviour I am seeing is that as soon as I break on
entry to the OnStop() method - the place where I need to fire the event -
the event/delegate member variable is null - someone (not me!) has clearer
all the delegates - so it appears that no one is interested in the service
shutting down - when there really are interested parties.
Does anybody know why this is happening? The service has member member
variables - some value types, some reference types, and they are all still
present and correct on entry to the OnStop() function, but any event member
variables have been cleared and are nulls.
Is this possibly as designed for some reason and Ive missed some piece of
documentation saying that events are cleared by the time the framework calls
OnStop for you?
Any help greatly appreciated.
Thanks,
Dan
|
|
|
|
|
I am using a textbox that has such fields as "name, address, phone numbers, and dates". I would like to format the phone numbers as '(999) 000-0000' and the dates as '01/01/1111'. I have tried several things that do not work. The sample by "Oscar Bowyer" is very complex I would like something very simple, is there anything? I need help!!!!!
|
|
|
|
|
Are your textBoxes bound to a dataBase table? If not, then have a look here[^] for the DateTime formatting. It's quite simple to follow and helps you get the picture behind it.
Regards,
Polis
Can you practice what you teach?
|
|
|
|