|
Addition to the previous post ... this works :
for (int i = 0; i < this.Controls.Count; i++ )<br />
{<br />
if (this.Controls[i] is TextBox)<br />
{<br />
this.Controls[i].Text = "";<br />
}<br />
}
I'm puzzled now
|
|
|
|
|
Rick van Woudenberg,
foreach (Control control in Controls)
{
if (control is TextBox)
{
TextBox textBox = control as TextBox;
textBox.Text = string.Empty;
}
}
Regards,
Gareth.
|
|
|
|
|
Hi remove the semicolon on the following statement
if (control.GetType() == typeof(TextBox));
then it should work
Regards
Srini
|
|
|
|
|
Hi ho
I've been experimenting with reading memory of other processes for a while now. And I've noticed the virtual addresses are quite weird.
First of all I can't access anything from 0x0 till 0xFFFF. This seems to be a forbidden area or so. :p I've never found a process that didn't have this 'offset'. The first readable address socket is 0x10000. I first thought this previous forbidden area (lower than 0x10000) was a Windows header or so, but it seems this 0x10000 and further is the windows header, including some data like the windir, cpu architecture, and so on.
Now you'd think the actual data of the process itself is just after this Windows header, but that's often not the case. Suddenly there's another piece of memory that's not accessible there. That keeps on going for a while.
Now I searched up some interesting addresses for certain processes (like the Minesweeper of Windows XP), and I can for example find the width and height of a minefield. But when you look at the actual address of this data, it's extremely high (relatively of course): 0x1005334. This is a hundred times higher than the first memory address that's accessible (0x10000).
I've researched a bit, but I can't find information about a certain structure Windows uses for process memory. Maybe there's a fixed virtual address where it actually starts to be interesting to read memory, because that's the actual memory allocated by the process itself?
Thanks in advance.
|
|
|
|
|
Hi,
virtual addresses get assigned by the linker, based on some defaults and a lot of optional
choices you can specify. It gets reported in the optional map file. As a result the address map
can be structured in many ways, all equaly valid.
Not sure how this is a C# question, Minesweeper is a lot older than any .NET stuff.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
I'm not talking about Minesweeper, I'm talking about any existing process that runs on Windows. :p I'd really like to find some pattern that can be used to find significant memory data more easily.
My final purpose is to make addons for applications that actually don't support addons.
|
|
|
|
|
Good luck then. I just told you things can be anywhere, it is a matter of choice.
Will your add-ons be programmed in C#? and apply to native code programs???
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thanks, hehehe. I'll just try to make a monitoring program first then, that logs what changes in memory. Then I can see what action changes which addresses.
Yes I will be making addons programmed in C#, applied to native code programs (as far as I know).
|
|
|
|
|
Hi Guys,
I need some help please. I have the following code being called in my timer_elapsed function and my timer is being enabled in the onstart of the windows service. This worked fine with .net 1.1 but ever since I have converted the application to .net 2.0, my service shuts down without notice when there is trafic in client requests i.e. ProcessClientRequest call. When I try to restart the service upon shut down it gives me an error saying "Only one usage of each socket address (protocol/network address/port) is normally permitted"
So I have to stop and wait a few and restart and it works fine and then again when there is much activity in processclientrequest call it shuts down.
I know this is not much information but please help me if you have any ideas.
Writ2ErrLog("Service Timer Initialized");
string sErr = "Application is ready for processing";
try
{
Writ2ErrLog(sErr);
m_tMonitor = new TD.Timer(new TD.TimerCallback(MonitorFunc), 1, 0, 45000);//45 sec
if (m_sServerAddr == string.Empty)
{
m_sServerAddr = Dns.GetHostName();
}
if (m_nPort == -1)
{
m_nPort = 1024;
}
IPHostEntry hostEntry = Dns.GetHostEntry(m_sServerAddr);
IPAddress ipAddress = hostEntry.AddressList[0];
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, m_nPort);
m_svSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
m_svSocket.Bind(ipEndPoint);
m_svSocket.Listen(10);
while (true)
{
try
{
Socket rtSocket = m_svSocket.Accept();
if (rtSocket.Connected)
{
TD.WaitCallback myCallBack = new TD.WaitCallback(ProcessClientRequest);
TD.ThreadPool.QueueUserWorkItem(myCallBack, rtSocket);
}
}
catch (Exception ex)
{
Writ2ErrLog(ex.Message);
break;
}
}
}
catch (Exception ex)
{
m_svSocket.Close();
m_tMonitor.Dispose();
sErr = "Start Error " + ex.Message;
}
finally
{
if (sErr != string.Empty)
{
Debug.WriteLine(sErr);
Writ2ErrLog(sErr);
}
}
Sameer
|
|
|
|
|
hi all,
i just want to read outlook express 6 contacts using c#. how to do that bcoz using outlook object library you can just browse only the outlook contacts but for outlook express how we can do that?
plz.. any one can help me out.
Regards,
kiran
kiran
|
|
|
|
|
Kiran, judging by the list of unanswered questions on the web, it appears Outlook Express doesn't support a programming model. You may have to manually parse the contacts file.
p.s. you're more likely to receive answers in this forum if you refrain from using text/IM speak like 'bcoz', 'plz', etc.
*edit* apparently it's possible, but possibly undocumented. see http://www.nektra.com/products/oeapi/[^]
|
|
|
|
|
Hi!
I get this confusing error when I start my program:
"this Cannot obtain value of local or argument '<this>' as it is not available at this instruction pointer, possibly because it has been optimized away."
The exception window pops up and I get: "NullReferenceException was unhandled" which this text also is visable "Object reference not set to an instance of an object".
What does this error mean? I'm tring to make a dynamic event. The error occurs where I have written the name of the event, when the event is so possed to start. Not where I have declared the delegate and the event.
/Mc_Topaz
|
|
|
|
|
Can you show us some code where it's occurring?
|
|
|
|
|
<br />
class Variant<br />
{ <br />
public enum e_Type<br />
{<br />
null_,<br />
bool_,<br />
int_,<br />
float_,<br />
double_,<br />
string_<br />
}<br />
<br />
e_Type m_type = e_Type.null_;<br />
public e_Type type() { return m_type; }<br />
<br />
private bool m_bool = false;<br />
private int m_int = 0;<br />
private float m_float = 0;<br />
private double m_double = 0;<br />
private string m_string = "";<br />
<br />
public delegate void DataChangedDelegate();<br />
public event DataChangedDelegate DataChanged;<br />
<br />
public Variant(bool val) { m_type = e_Type.bool_; m_bool = val; DataChanged(); }<br />
<br />
public static implicit operator Variant(bool val) { Variant V = new Variant(val); return V; }<br />
<br />
<br />
}
<br />
This is the code which contains the event and delgate stuff.
I get the problem when the program comes to "DataChanged();" inside "Variant(bool val)".
If I run this statement, the error occurs as described earlier:
Variant a = true;
If I put a breakpoint at DataChanged();, The debugger reports:
"<this> Cannot obtain value of local or argument '<this>' as it is not available at this instruction pointer, possibly because it has been optimized away."
I hope you can help me.
modified on Tuesday, February 26, 2008 3:58 AM
|
|
|
|
|
Are you running under Debug mode? Usually I get that debugger error when I'm debugging an app built in Release mode.
In any case, if all else fails, just print the exception details to the output window via Debug.WriteLine. (Or perhaps its as easy as gareth says, and it's just that your event has no listeners.)
|
|
|
|
|
Mc_Topaz,
If (eventName != null)
new eventName();
Regards,
Gareth.
|
|
|
|
|
Hi all,
Just now I ran into a problem concerning the datagrid and it's row selection.
Currently I'm using the datagrid to select a whole bunch of data from a database. When I click a row it opens a new window with
e.Item.Attributes.Add("onclick", "window.open('whateverpage.aspx?action=id="((DataRowView)e.Item.DataItem).Row["id"].ToString()')"
this (well not exactly that but thats not the point) is included in the datagrid's itemcreated handler.
The datagrid's datasource is a table from the database as to auto generate the columns ( must auto generate btw) and I add a buttoncolumn code-wise.
Now the problem is when I click the button it first handles the row selection, and as such it opens up the new window, which I want to avoid. After all this it finally handles the button, which works fine.
So how do I disable the onclick event ( the row event) for the button column, or I guess any way to avoid the new window popping up is appreciated.
I hope this is possible, if it is not, an acceptable work around would be to close the new window from the button handler ( from the old page)... but I haven't been able to figure out how to do that, since I don't know how to close the new window from the old one or how to pass a (session) variable to the new window before the page loads.
So to clarify , I have a datagrid with selectable rows and a button column. When one selects the button from the buttoncolumn it also selects the row and thus opens a new window before the button is handled.
Hopefully this is enough information to solve the problem, please let me know if I should post additional info to clarify the problem.
Thanks in advance!!
modified on Thursday, February 28, 2008 11:00 AM
|
|
|
|
|
hi
can anyone please tell me how to use POP3 Protcol to open gmail or any website...
thanks
|
|
|
|
|
|
Hi,
I would like to round a decimal number and assign it to string:
so a decimal number such as 8.54 becomes 9
8.2 becomes 8
...
Present code:
ys.YAS_BOND_PX = dp.Value.ToString();
to round up something like as follows:
ys.YAS_BOND_PX = Math.Round(decimal.Parse(dp.Value.ToString()));
Error is :
Cannot implicitly convert type 'decimal' to 'string'
How do I solve this please?
Thanks
|
|
|
|
|
Is ys.YAS_BOND_PX a string? If so, that's your problem. Math.Round returns a decimal so you'll need to add a .ToString() at the end to convert it.
Dave
|
|
|
|
|
arkiboys wrote: ys.YAS_BOND_PX = Math.Round(decimal.Parse(dp.Value.ToString()));
You take the value, convert it to a string , parses is as a Decimal , rounds it, and try to put the Decimal value in a string property?
I think that this is what you are trying to do:
ys.YAS_BOND_PX = Math.Round(dp).ToString()
By the way, don't use the Decimal data type unless you really need it's precision (e.g. monetary applications). The natively supported data type preferred for regular floating point numbers is Double .
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi,
I am using following line of code in a for loop to populate a multiline textbox.
this.textBox2.Text = this.textBox2.Text + '\n' +oCompResult.Errors[i].ErrorText.Trim();
I need to show each array item in separate line.But it doesnt happens even if there is a '\n' present.
Pls help.
|
|
|
|
|
try:
textBox2.Text += Environment.NewLine + oCompResult.Errors[i].ErrorText.Trim();
You'd be better off using a StringBuilder for this and setting the textBox2.Text after the loop. Simple example below...
string[] sArray = { "a", "b", "c" };
StringBuilder sBuilder = new StringBuilder();
foreach (string thisString in sArray)
{
sBuilder.AppendLine(thisString);
}
textBox2.Text = sBuilder.ToString();
Dave
modified on Monday, February 25, 2008 8:18 AM
|
|
|
|
|
since your output is line oriented, you should consider a ListBox instead of a TextBox;
it does not need the concatenation of all strings, just a simple
this.ListBox1.Items.Add(oCompResult.Errors[i].ErrorText.Trim());
would do it for whatever number of lines you have, without a quadratic performance hit.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|