|
Thank you. I'm looking for a clean way to detect whether the script function exists before attempting to exec it also. The program needs to fail gracefully and this interface doesn't seem to give me that option.
|
|
|
|
|
Then wrap that functionality in a try-catch block and handle the exception in the catch block.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I did that initially. The problem is that you blindly invoke a script that doesn't exist and the browser catches the error. This is what I'm trying to prevent.
Thanks.
|
|
|
|
|
Then get the IHTMLDocument2 interface, get an IHTMLElementCollection from its scripts property, then enumerate the IHTMLScriptElement objects in the collection. There's various properties on said element that can help you identify what's in it. You can query the text element for a simple pattern match: "function[\s]+(\w+)".
Each match will be your function name.
The only other way that seems possible is to get the IHTMLDocument and get the IDispatch to the script engine from the Scripts property. It's not well documented what this is, but it seems evident that you could call IDispatch.GetTypeInfo , then from the ITypeInfo reference you get back (you may have to define this interface using the appropriate GUIDs and what-not yourself), call ITypeInfo.GetNames , then use the BSTR array to call IDispatch.GetIDsOfNames . Once you get those IDs, you can invoke them using IDispatch.Invoke .
All these interfaces - except for ITypeInfo - should already be defined in the Microsoft.mshtml.dll assembly. ITypeInfo shouldn't be hard to define since you only need to define the interface so that the interface GUID, interface type, and optionally DispIDs match-up to the way the native interface is defined, taking into account all out and ref keywords, as well as necessary values in the MarshalAsAttribute and OutAttribute for interop.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I would like to know of a resource that has details on available namespaces. for example in C++ I'd use iostream.h for i/o operations, but in C# I do not know what I would use (all I know are System and Collections, but no details on the functions within them).
Can anyone suggest somewhere?
Obseve everything, remember more...
|
|
|
|
|
|
Nick's advice is what I would give you, too. But I wanted to throw in some things here:
You'll also want to read articles on sites like this one and C-Sharp-Corner[^].
tom76 wrote:
in C++ I'd use iostream.h for i/o operations, but in C# I do not know what I would use
System.IO has many helpful classes for this - File and FileInfo for working with files, Directory for working with directories, Path for working with paths, and FileStream, TextWriter, TextReader, StreamReader, StreamWriter, etc for reading and writing to files.
|
|
|
|
|
Does anybody know a good HTML parser written in .net hopefully C#. I'm automating IE right now and I'm looking for something that handles real world HTML with low overhead.
|
|
|
|
|
andy brummer wrote:
I'm automating IE right now and I'm looking for something that handles real world HTML with low overhead.
So, why not use MSHTML.HTMLDocument? With this, you'll use IE's parser engine and you'll have the least overhead possible, as you'll use the very same IE that's in memory.
Trying to make bits uncopyable is like trying to make water not wet.
-- Bruce Schneier
By the way, dog_spawn isn't a nickname - it is my name with an underscore instead of a space. -- dog_spawn
|
|
|
|
|
I'm using C# right now and the casting required is driving me crazy. Also, I'd rather not have to do the interop and I don't need the overhead of loading the mshtml parser. Plus this is in a library that could be run server side, and even though I can run with visible false, the objects are still appartment threaded and all that.
I just need something simple that will allow me to parse out the tags and attributes with the heirarchy without running embeded script, or requiring XHTML.
|
|
|
|
|
andy brummer wrote:
I just need something simple that will allow me to parse out the tags and attributes with the heirarchy without running embeded script, or requiring XHTML.
I would go for some free Java HTML parser. There are some very good ones out there and it's a breeze compiling most of them with J# and using them from C#. I've done some similar things with PDF libraries in the past and it was very quick and easy.
Trying to make bits uncopyable is like trying to make water not wet.
-- Bruce Schneier
By the way, dog_spawn isn't a nickname - it is my name with an underscore instead of a space. -- dog_spawn
|
|
|
|
|
Thanks, there are a ton of those out there. I didn't think of using J# to try compiling them to .net.
|
|
|
|
|
If IE is already loaded (which it seems to be by the description in your first post, there is no overhead because you're merely using the interfaces that are defined in the MSHTML typelib, and the interfaces are references to what's already loaded in IE's WebBrowser control (which hosts MSHTML).
As far as casting goes, that's just part of development. Besides, .NET allows you to simply cast where in C++ you have to QI (QueryInterface) a pointer for a particular interface, check the return, and AddRef. It's by far more tedious. Feel fortunate!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Well, the only reason I loaded IE is for the parsing , just to get something up and running. Trust me, I've done more then my share of automating IE with C++. I find it more painful to do it in C#, just because everything else is so easy.
If I was really going to use IE, I'd drop down to VB.net anyway sad as that may be.
|
|
|
|
|
Hello,
is there any chance to access the keyboard buffer directly using c# ?
Thanks,
Stux
|
|
|
|
|
I would like to get a list of images associated with file extentions on a base system to make my application look more proffesional.
I will have a list of extentions that I will want for each list view that is activated, and would only require a look up the icons as it is activated (Unless there is a better way of doing this, but i'd like to avoid importing every image in the system).
How can I get a list of icons, and their association from the system?
Thanks
Cata
|
|
|
|
|
|
Hi, I'm making the LineChartControl.
I want to provide controlable interface to user.
It's means, if you add a line to chart, then LineChartControl add a layer to Control like a PhotoShop.
Also can control a line's visible status.
It's applicable to make a drawing Application.
Please, give me an idea.
|
|
|
|
|
A layered image is really lots of images drawn on top of one another. You can create this by selecting a colour to be a transparency mask, making images with this colour to start with and using the draw method that takes a colour range to draw transparently. Or you can do it manually, as photoshop would, by maintaining a 1 bit image as a mask for each layer.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I have a question about replace system DLL with my owens.
then I can use my functions to repleace API functions.
As far as I know ,I must wirte DLL with C++.I have seen
some code about it .It use ASM in it.That is ok .
but in vc++,we can do it with the help of _ASM{ }
but when I want to do it use C#.I do not know anything .
I hope someone to help me. Thank you .
sdfasd
|
|
|
|
|
There is so many things wrong with this I don't know where to begin...- You can't replace system DLLs in newer OSes because they'll put the cached copies right back.
- I doubt your coding is any better than a large team of Microsoft developers.
- You can't replace system DLLs with managed assemblies because native DLLs are loaded directly without a host for the CLR by the executable loader.
- You can't use assembler in managed code because assembler is as unmanaged as you can get, but you can use unsafe code for pointer manipulation.
And if you say something like - and I quote - I do not know anything ., that's a pretty good sign that you shouldn't start replacing any DLLs because it's not a trivial task and - as I said before - isn't possible in newer Windows OSes (unless System Restore is turned off).
Besides, you would have to replace ALL functions exported in a DLL and - many times - several of those functions are undocumented so there's no way to know what they should do based on any given set of parameters.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
lajiyo wrote:
I do not know anything .
Amen.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
That sounds like a really bad idea. Why on Earth do you want to replace system DLLs?
I am so glad that modern OSes see this happening and say "Sod this for a jaffa-cake" and restore the appropriate DLL.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
|
|
|
|
|
csc -nostdlib
Now have fun and contact us when you done
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Hi, everybody.
I have a little problem.
I use for work with database 'Microsoft Jet 4.0 OLE DB Provider', but I have a problem with integration of the project. How can I install only 'Microsoft Jet 4.0 OLE DB Provider'.
Thank's.
|
|
|
|