|
My problem relates to the code below, and I cant understand why its happening. I have to use the int test as the values I declared do not work. If you add a watch to guid, amount or serial, the watch value says that these are out of scope, and as such, nothing is assigned to them. If however I add in the int test, and assign it (as shown below), the program works. Any ideas?
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
string guid = "a";
int amount = 1;
byte[] serial = {1};
int test;
test = guid.Length;
test = amount;
test = serial.Length;
amount = r.ReadInt32();
guid = r.ReadString();
serial = r.ReadBytes(32);
r.Close();
fs.Close();
|
|
|
|
|
didn't understand
toticow wrote:
If you add a watch to guid, amount or serial, the watch value says that these are out of scope
when are they out of scope? after u've assigned them, without the int test ?
there are no facts, only interpretations
|
|
|
|
|
I a list view control before removing item(s) I am prompting the user with a message box "if he really wants to delete the item(s)". If the answer is "YES" then the item(s) are removed. when the answer is "NO" then the item(s) are not removed as it should be; but the selected item(s) are not displayed as selected that is hot items with rectacle showing the selection effect. How to show that rectangle?
In another way is to send the LVM_SETHOTITEM message which will show the items as selected. But I don't know how to send a message in C#
|
|
|
|
|
eDip wrote:
In another way is to send the LVM_SETHOTITEM message which will show the items as selected. But I don't know how to send a message in C#
Try the following:
int LVM_SETHOTITEM = 0x103C;
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, IntPtr lParam);
SendMessage(lvwCtrl.Handle, LVM_SETHOTITEM, index - 1, 0);
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi guys,
I want to ask how to call an external app from C# (a command like Shell command in VB.Net or ShellExcute in VC++).
Thank your.
|
|
|
|
|
|
Thank you for your answer. I had tried and ok. But I want still to know a command in C#, with functionality as Shell or ShellExcute command. Is there a such function in C#? and if yes, What is this? Could you tell me. Thank you very much
|
|
|
|
|
I'm pretty sure, there is not, but the combination of Process and ProcessStartInfo classes should provide everything to customize the startup of an exeternal program.
If not, try to p\invoke the ShellExecute method.
www.troschuetz.de
|
|
|
|
|
I'm trying to remove some items from a listbox but always get failed.
Assume one listbox item's text is "ItemText", value is "New", and index is 1.
I tried the following code to remove this item from a listbox:
ListBox.Items.Remove("ItemText");
Nothing happened after I run this code.
But when I used this: ListBox.Items.RemoveAt(1);
Then this item was removed.
Now I'm in a situation that I cannot get the index of a certain item. Then how can I remove this item if I only know it's text?
Thank you for your help!;)
|
|
|
|
|
You can check if an item is present by using the method Contains.
if (myListBox.Items.Contains(targetObject))
{
//then do something
}
You can get the index of a particular item by using the IndexOf method:
myListBox.Items.RemoveAt(myListBox.Items.IndexOf("ItemText"))
Also, here is some uncalled for advice: When you are deleting multiple rows in the listbox, start deleting items from the bottom.
Cheers
~/sathishvj
|
|
|
|
|
Thank you for your reply;).
I tried Items.IndexOf("ItemText") but the argument of indexof() must be a listitem but not a string or an integer.
Now I find I could make it in this way:
ListItem myitem = new ListItem("ItemText", "ItemValue");
myListBox.Items.Remove(myitem);
That could solve my current problem.
But if I couldn't get the value of t;)he item then I still can not remove it.
|
|
|
|
|
You can always get the index of a ListItem. Try using:
int itemIndex=listBox.FindStringExact("ItemText");
if (itemIndex>-1)
{
listBox.Items.RemoveAt(itemIndex);
}
|
|
|
|
|
Hi,
I am trying to write a service that will automatically change the wallpaper. The SystemParametersInfo call works from a normal windows application but not from a service.
The return value is 0 and I can debug that the error I get is "Unable to find an entry point named SystemParametersInfo in User32.dll".
Would anybody be able to help me figure out why this happens and how to get around it?
Thanks and regards
Sathish
Some code:
public class WinAPI{
//various stuff I tried in DllImport
//[DllImport("user32.dll", EntryPoint="SystemParametersInfoA", CharSet=CharSet.Auto, SetLastError=false, ExactSpelling=true)]
//[DllImport("user32.dll", CallingConvention=CallingConvention.Winapi, SetLastError=false, ExactSpelling=false)]
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SystemParametersInfo (int uAction , int uParam , string lpvParam , int fuWinIni) ;
}
//different ways I tried to call it from within the service
int nResult = WinAPI.SystemParametersInfo(20, 1, bmpFilePath, 0x2);
//int nResult = WinAPI.SystemParametersInfo(20, 0, bmpFilePath, 0x1 | 0x2);
~/sathishvj
|
|
|
|
|
I tried doing something like this. When I changed the properties of the service to allow interaction with the desktop it changed the return value of SystemParametersInfo to 1 instead of 0, but i did not see a change to the desktop still as I do in a regular app.
Maybe it is because I have windows 7, try this for XP.
|
|
|
|
|
Hi everybody!
I am using Net.2005b.
When i used unsafe functiuon with fixed keyword in it , the watch window work not properly. There are ""Unable to evaluate expresion"" message for all variables.
The "Autos" and "Locals" windows are empty.
For example
namespace ConsoleApplication1
{
class Program
{
public int index;
static void Main(string[] args)
{
Program pr = new Program();
pr.test();
}
public unsafe void test()
{
index=10; //at this point watch window not work correctly
fixed (int* j = &index)
{
*j = 20;
}
}
}
}
What is the problem?
|
|
|
|
|
|
I want to know is this problem in beta version or only in my installed version of Net?
|
|
|
|
|
Is there a way to make a MDI or SDI application, which already have menus, like File, Edit, View, just like VC++6 does? Heavy job, creating the menus manually
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
If you are using VS.NET <= 2003 : No.
The next version will have that feature
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
Oh comon. It can't be that hard.
I takes about 5 minutes to get the base items in VS.net and attach all the handlers.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
To test different cardreaders,I wrote a program to do the write/read data test.At first,copy a file of certain size form Harddisk to the cards,and then read the file form every card(s) and campare the data with the source file data.According to the capacity of each
card,I should choose comparative file size from a ComboBox,such as 1MB,32MB,64MB,512MB,1GB,ect.Amd what's more,I can not know what the number my user will input to the ComboBox.So,my question is:If there is a way to let me read 1GB(or some other number>1MB) data from a file(size more small and more better.)?
Thanks!
|
|
|
|
|
momer wrote:
To test different cardreaders,I wrote a program to do the write/read data test
This makes sense.
momer wrote:
If there is a way to let me read 1GB(or some other number>1MB) data from a file
Well. See System.IO . BinaryReader , FileStream ... but it seems like you're looking for a
file-compare function in C#[^]
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Hi!
Thank you!
//at present,before test,I must choose the
//sourcefilename which meet the proper size of the
//card to be test.The following code can do the right
//thing when I offer the correct sourcefilename.
......
FileStream sourcefile = new FileStream(sourcefilename,FileMode.Open,FileAccess.Read,FileShare.Read,4096,true);
File.Copy(sourcefilename,destfilename,true);
FileStream destfile = new FileStream(destfilename,FileMode.Open,FileAccess.ReadWrite,FileShare.ReadWrite,1024,true);
destfile.Seek(0L,SeekOrigin.Begin);
sourcefile.Seek(0L,SeekOrigin.Begin);
while (((i = sourcefile.ReadByte())==(j = destfile.ReadByte()))&&(i!=-1)&&(j!=-1));
if ((i==j)&&(i==-1))
{
mylusbs[threadnumble].Text = "PASS!";//currentlusb.text = "PASS!";
mylusbs[threadnumble].ForeColor = System.Drawing.Color.Blue;
}
......
? can you offer me a way to create 1GB file from 1MB file
Thanks!
momer
|
|
|
|
|
I don't quite understand how the above code is related to creating a 1GB file but...
Use FileStream and write your 1MB chuck 1024 times. I guess that would work right??
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|