|
You can write a separate method and call it from button and menu events. It's called code centralization (I think). At least I do that.
|
|
|
|
|
|
Thanks for the help.The problem is that i am desinging my
own harware stereo fm radio which has a usb connector
which is plug into the usb port of the system,whether
i write driver for this particular device or a dll for
using it in c#.Net and control it?.kindly tell me the
proper solution for the above query.waitng for your replys....
@hs@n
|
|
|
|
|
I am trying to write a C# program to read a binary file. The records have a predefined strucutre. Problem is I have no idea to to define the struct in C# in the way I did in C++. I also need the strucutre to be in 1 byte alignment.
In C++ the structure looks as follows:
#pragma pack(1)
struct my_struct_
{
unsigned char fld1[10];
long fld2;
short fld3;
};
#pragma pack()
I tried the MSDN but the examples looks so complicated I can't understand a thing..
|
|
|
|
|
Take a look here[^] for a good tutorial on C# structures.
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Thanks for that. However, I still don't know to force 1 byte strucutre member alignment and array of bytes?
|
|
|
|
|
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
|
|
|
|