|
Spy++ gets you the hwnd.
You use the hwnd in your code.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I dont know how to use SPY++ in run time.
Is there some example ?
|
|
|
|
|
You could try running it... There's always google.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Use FindWindowEx[^] through pinvoke to find the button. You can use the handle for the parentwindow parameter and the caption of the button for the caption parameter. After getting the handle for the button you can send the BM_CLICK message using SendMessage[^].
|
|
|
|
|
Hi,
I have a large (0.5GB) XML file. I'm effectively copying it at the moment (with a view to changing certain values in the xml for testing). I'm using the XmlTextReader and Writer to perform this task.
Here is my code:
static void ProcessNode
{
if (reader.NodeType == XmlNodeType.Text)
{
string source = SecurityElement.Escape(reader.Value);
writer.WriteRaw(source);
return;
}
}
static void ProcessFile(XmlTextReader reader)
{
reader.Read();
using (XmlTextWriter writer = new XmlTextWriter(destinationPath, reader.Encoding))
{
Process(reader, writer);
while (reader.Read())
{
ProcessNode(reader, writer);
}
}
}
static void Main(string[] args)
{
using (XmlTextReader myReader = new XmlTextReader(sourcePath))
{
ProcessFile(myReader);
}
}
I'm having problems with escape sequences. The line string source = SecurityElement.Escape(reader.Value); Unescapes "'" to ' and "<" to < etc, which is desired. My problem is this: I have accented, non-english characters that have the escape sequences (e.g. Ú should be written as Ú). I cannot figure out how to Unescape such caracters.
As a side note, the line writer.WriteRaw(source); was writer.WriteString(source); both with and without the SecurityElement.Escape writes even the apostrophe unescaped, as well as the non-English caracters I'm still having problems with. This seems to be in direct opposition to http://msdn.microsoft.com/en-us/library/system.xml.xmltextwriter.writestring.aspx[^] as far as I can tell.
If anyone can spot where I've gone wrong, it would be appreciated, this should have been a 1/2 day task for me and has taken a day so far....
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
I prefer to use an XmlDocument.
|
|
|
|
|
I agree, but reading the whole doc in results in out of memory exception. Reading nodes in at a time is much slower (factor of 100) than my current code, on a half-gig file. I'm hoping someone has a simple and fast answer to my problem....
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Don't use XML for half a gigabyte of data
|
|
|
|
|
I've no control over the source XML, otherwise a) I wouldn't use XML for half a gigabyte of data b) Even if I did, the encoding wouldn't be screwed up the way it is in the first place.
Worryingly, my source XML comes from a financial institution much bigger than the one I work for. The guys who produced it are, I assume, getting paid much more than me.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Yes, but then you have to write your own parser and you may still wind up loading an element that doesn't fit in memory; the root element for example.
|
|
|
|
|
XmlWriter has a WriteCharEntity method, which converts chars into their element/escaped equivalents, so all I need to do is convert chars not in the range "space" to "tilde" (ie non-latin characters) to determine this
static bool CharacterNeedsEscape(char c)
static bool CharacterNeedsEscape(char c)
{
return c > '~' || c < ' ';
}pre>
Now the text node handling code checks each character in turn, if an escape is not needed the raw character is written, otherwise the <code>WriteCharEntity</code> method is called.
<pre>if (reader.NodeType == XmlNodeType.Text)
{
string startingString = SecurityElement.Escape(reader.Value);
char[] chars = startingString.ToCharArray();
for (int i = 0; i < chars.Length; i++)
{
char c = chars[i];
if (!CharacterNeedsEscape(c))
writer.WriteRaw(chars, i, 1);
else
writer.WriteCharEntity(c);
}
return;
}
The code isn't pretty, but it is fast enough for my purposes....
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Hi!
Perhaps a bit late, but I just needed something similar and found System.Web.HttpUtility.HtmlDecode() and System.Web.HttpUtility.HtmlEncode() , which works just fine in my case.
Perhaps it's useful for you, too.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi All,
I want to execute and executable file from service using thread. can any body tell me how to execute and exe with 5 minute interval?
I am executing exe from service but it gives me below error in JIT Debugger.
An unhandled exception ('System.InvalidOperationException') occured in Servicemanager.exe[3300]
Thanking You,
Sunil G.
modified on Monday, January 18, 2010 6:49 AM
|
|
|
|
|
Creates a Process object and call Process.Start() every five minutes. Keep in mind that the process object runs the executable with the same user permissions as the user under which the service was installed. I write windows services by creating the core code in a console application, where it's easier to run the debugger and you don't have to hassle with service install/uninstall crap while you're developing.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I am using below process to do. but it gives me an error as mentioned earlier.
Process myProcess = new Process();
myProcess.StartInfo.FileName = "G:\\Code\\New Folder\\Monitor\\ServiceManager\\Copy of SVCManager\\ServiceManager\\ServiceManager\\bin\\Release\\ServiceManager.exe";
myProcess.Start();
User is the same.
What is wrong in this?
|
|
|
|
|
Did you look at the inner exception under the debugger?
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
The exe i am executing is a GUI application.
If i run a silent exe it runs properly.
it only gives an error while executing GUI exe.
I dont have depth knowledge.
can u explain how to look into inner exception?
|
|
|
|
|
Sunil G wrote: I dont have depth knowledge.
can u explain how to look into inner exception?
Have a look at Exception.InnerException Property
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
You have to run the service under the debugger
[^].
The only thing I can think of is that a GUI app can't run if there is no user currently logged in.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Dear all,
Is there a way to create excel files and write data into excel files using C#, without the installation of MS Excel on the computer?
Thanks in advance.
|
|
|
|
|
There are some components out there (for example XLSReadWriteII.NET) but which versions of excel file format they support (and they are all different) is another matter.
If you are talking about creating the file and writing into it, why not use a CSV file, which is simple to create, simple to amend, and any flavour of excel can read them.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
I can't use csv, it most be xls.
What about using the oledb? with oledb u can also easly read and write excel, bud do you need then MS Excel for this?
|
|
|
|
|
Haven't tried it myself, but this says YES YOU DO[^] which makes sense to me.
Have you considered farming the excel stuff to a server which does have excel loaded (I assume it is the cost that stops you installing on all machines)?
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
Use OleDb. it does not require excel to bee installed on the client computer.
However the file must be created first. Then fill it with data.
Also note that there is no UPDATE in using OLEDB/Jet with Excel files. A way around is: delete and add.
|
|
|
|
|
NPOI[^] will do this, open source too
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)
|
|
|
|