|
You can't! At least one of them must be visible to the other.
The best solution is to use a server which is visible to both.
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
Hi all, i asking about marshalling, what it is means, and why we need it???
I face this statment at some code, but i don't know exactly what it means ..;
< // Marshal pointer into a struct
PcapUnmanagedStructures.pcap_if pcap_if_unmanaged =
(PcapUnmanagedStructures.pcap_if)Marshal.PtrToStructure(nextDevPtr,
typeof(PcapUnmanagedStructures.pcap_if));
>
|
|
|
|
|
I'm no expert so this is a rough overview. I'm sure Luc will be along soon to offer a much better description!
Marshalling is data transformation. Things in the managed world are different from the unmanaged world and marshalling takes care of transforming the data so we can pass it between the two worlds.
Unmanaged code often uses pointers to pass the references to values rather than the values themselves. These pointers are marshalled back to managed code to an IntPtr. To get the actual value pointed to, we can use the Marshal class to transform the data at the given reference to a structure as in your example.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
That is just fine, no way to improve on it.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Hello
I have an list array of strings that I would like to display in a list box.
List<string[]> Param = new List<string[]>();
if I do
for (int index = 0; index < Param.Count; index++)
{
listBox1.Items.Add(Param[index][0]+"\t"+Param[index][1]);
}
The output is all skewed depending on what the length of the first string is.
How can I make this a multicolumn listbox, writing each string to the appropiate colummn?
Thank you in advance.
|
|
|
|
|
You should either use a ListView (in Detail view) or a DataGridView as they are multicolumn controls.
Alternatively you could use a fixed width font and calculate the correct position of the second column based on the longest length of the first string - fugly but it will work!
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I tried creating a DataGridView
But when I set the
dataGridView1.DataSource = Param;
it only list the information about the Param structure and not the data inside.
Are you able to show me how to add to the DataGridView data?
Thank you in advance
|
|
|
|
|
See Alex's answer below
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
try this:
for (int index = 0; index < Param.Count; index++)
{
listBox1.Items.Add(Param[index][0]+"\t\t"+Param[index][1]);
}
note:
i use this method before to show lists but it is so hard to get the data back from it so try datagriadview there is more options you can do with it.
|
|
|
|
|
for (int index = 0; index < Param.Count; index++)
{
datagridview.Rows.Add(Param[index][0],Param[index][1]);
}
but you should add col. before you do that:
datagridview.coluomn.Add("1","1");
datagridview.coluomn.Add("2","2");
|
|
|
|
|
hi,
you can use a DataGridView contorl.
Example for you're list like this:
dataGridView1.Columns.Add("column1", "Column1TextToDisplay");
dataGridView1.Columns.Add("column2", "Column2TextToDisplay");
foreach (string[] param in Param)
dataGridView1.Rows.Add(param);
Pretty easy, huh ?
Cheer's,
Alex Manolescu
|
|
|
|
|
Thank you!
It works great, something I can really build on in my project.
Douglas
|
|
|
|
|
You're welcome. Don't forget to rate my reply
Cheer's,
Alex Manoelscu
|
|
|
|
|
I know of two ways to get a ListBox show tabular stuff as you would like it:
1.
use a non-proportional font, such as Courier New (for logs, numbers, etc that is what I do);
2.
make it OwnerDrawn, i.e. provide a DrawItem handler, where you do a Graphics.DrawString() for each of the "columns"; that is what I do when I want one or more columns to use proportional fonts, and/or want to include non-textual information such as icons.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Hi,
I'm new here, and just recently I've been trying to make a program that modifies some registry keys. Don't worry, this isn't malicious. And this is the first time I've coded in quite some time... so i am rusty.
Here goes, I want to automate changing the status of an audio device from enabled to disabled. The issue lies in I get kicked back when using the RegistryKey.OpenSubKey method when I try to have write access. When I get read access, it does open but then I can't change the DeviceState value to disable the device. I have tried using both RegistryPermission & RegistryAccessRule... I had luck with neither. I also went as far as creating a batch file that used "subinalc.exe" to take ownership of the key and then attempt to open it... still nothing.
I tried googling this, but I haven't found anything that proved useful. So my question is, is there a class I could be using that would let me take possession of the key? Or is there another class to set permissions that I haven't found?
I am running VS 2008, and I have tested on two different Win 7 systems (one x86 & one x64).
|
|
|
|
|
From Vista onwards certain parts of the reigistry require the application to be elavated. Adding an application mainfest file and requiring administrator as described here[^] may solve your issue.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I forgot to add that in the original post. I already created the manifest requiring an elevated status.
|
|
|
|
|
OK, if the used doesn't have an admin account, it's not going to work no matter what you do. Virtually everything under HKEY_LOCAL_MACHINE is read-only to normal user accounts.
What's the pat you're trying to write to?
|
|
|
|
|
From within the registry editor there is a permissions window Edit->Permissions which allows you to assign permission to users for keys.
|
|
|
|
|
I'd be very grateful for some help.
My project is as follows:
The user can enter a choice of pizza type; thin crust, medium and thick crust.
Then they can choose the size between 100mm and 1000mm.
The thin crust has a base price of £2.50, the medium £5.00 and the thick £7.50.
Then I need to calculate the size of the pizza selected, add the base price, and let the user confirm their selection.
The confirmed selections have to be appended to a text file with a date stamp. The file should keep adding confirmed records every time the program is run. (crust type, size, cost, and date)
I am still battling with the basics, and hopefully getting on with this project will help.
So far my code is:
string[] size = new string[3];
size[0] = "thin crust";
size[1] = "medium crust";
size[2] = "thick crust";
Console.WriteLine("Enter type of pizza required: 1 = thin crust, 2 = medium crust, 3 = thick crust: ");
int result = int.Parse(Console.ReadLine());
Console.WriteLine("You have chosen the {0} pizza", size[result - 1]);
Console.ReadLine();
}
areaM2:
{
float x;
Console.Write("Please enter number, between 100 and 1000: ");
x = float.Parse(Console.ReadLine());
if ((x >= 100f) && (x <= 1000f))
{
Console.WriteLine("Your number {0} is between 100 and 1000", x);
Console.ReadLine();
}
else
{
Console.WriteLine("You did not enter a valid number: ");
Console.ReadLine();
goto areaM2;
}
}
size[0] = 2.5;
size[1] = 5;
size[2] = 7.5;
x = x * x;
Console.ReadLine();
It would run until I added the last few lines. If someone could tell me how to proceed by assigning the base prices to the sizes, and adding them to an equation, I would be very grateful.
Thanks to those people who helped me earlier, but I think I posted in the wrong place, sorry.
|
|
|
|
|
You put the declaration of x in a "weird scope which is there without reason", so it disappeared by the time it gets to the x = x * x
Solution 0: remove the useless scope
Solution 1: move float x outside the scope
Solution 2: move the calculation inside the scope
btw you should probably change that nasty goto into a do-while
|
|
|
|
|
Ok, there are a couple of problems here!
1) DON'T USE GOTO! Replace that with a "while" loop, and use a bool to control continue around / exit (there are other ways, but that is simple to do and understand). Never use GOTO until you are experienced enough to know when you should!
2) You have declared "size" as an array of strings - you cannot then use it as an array of floats. That is like making space on a bookshelf then trying to store car engines - it doesn't work. Create a new array of floats, or use an if...else if...else instead.
There are other (future) problems, such as what happens if the user enters a pizza type of -1, or 6 - but they can wait until the main logic is sorted.
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
I've improved the code I think:
string[] pizza = new string[3]
{ "Thin Crust",
"Medium Crust",
"Thick Crust"};
Console.WriteLine("What type of pizza do you want? Enter number, ");
for (int i=1; i<4; i++)
Console.WriteLine("{0} {1}",i,pizza[i-1]);
int result = int.Parse(Console.ReadLine());
Console.WriteLine("You have chosen the {0} pizza", pizza[result - 1]);
Console.ReadLine();
float x;
Console.Write("Please enter pizza size, between 100 and 1000: ");
x = float.Parse(Console.ReadLine());
if ((x >= 100f) && (x <= 1000f))
{
Console.WriteLine("Your number {0} is between 100 and 1000", x);
Console.ReadLine();
}
else
{
Console.WriteLine("You did not enter a valid number: ");
Console.ReadLine();
I've played around and can't figure out how to get the 'do,while' to work when entering invalid figures
|
|
|
|
|
|
can I really order pizza's from you, with diameters that are millimeter accurate, and go all the way up to one meter? Do you do home delivery? And are they free when undelivered within 30 minutes, as is the general rule over here? I'm interested! Please send me menu and contact info...
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|