|
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.
|
|
|
|
|
I've already answered your questions, and I am a professional consultant for several companies (in the past and currently) for Windows Installer, and am currently working on the MSI 3.0 beta testing team.
Notice the emphasized string in 'Microsoft Jet 4.0 OLE DB Provider'? That means that it is an OLE DB provider and that requires the MDAC 2.6 or above to use with ADO.NET. There is simply no way around it.
You need to install the MDAC 2.6 or higher MSM. You can find these all over the 'net and it is easy to make. As I stated before, InstallShield has both MSMs for MDAC 2.7 SP1 (http://saturn.installshield.com/isd/mergemodules/801/MDAC27/MDAC27ENU.msm[^]) and Jet 4.0 SP6 (http://saturn.installshield.com/isd/MergeModules/EnglishMM/Jet40SP6/Jet40.msm[^]). They do have MSMs for MDAC 2.8 and Jet 4.0 SP7, but there's no link to download. See the following page for many more merge modules to download: http://www.installshield.com/downloads/modules.asp?prod=wind&lan=english&xmlUse=y[^]
All you need to do is add these MSMs to your project correctly. That's it. They are called merge modules because the tables that make up the MSM are merged with your installer when your install package is compiled. The only thing you might have to do is specify a target redirect (or default path) for the files in the MSM when you add it. Just specify the Windows\System32 directory ([SystemFolder] in Windows Installer) and that's it.
-----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-----
|
|
|
|
|
Hi
Im try to get the icq api to work in c# but i trapped into a big problem.
The dll-function:
ICQAPICall_GetOnlineListDetails
BOOL WINAPI ICQAPICall_GetOnlineListDetails(int &iCount, BPSICQAPI_User **ppUsers);
In (Arguments): None
Out (Returns): iCount, ppUsers
iCount - the number of Users to follow
ppUsers - a pointer to the users’ array.
Description: The data returned is in the order of the online list, top to bottom. The users array is initialized with the user’s ICQ# (m_iUIN field) and the Window Handle (m_hFloatWindow) if the user is “floating”. The users array should be freed by calling ICQAPIUtil_FreeUsers to free each user structure and the array itself.
The iCount Parameter i get correctly with passing "out iCount" to the function (it will return the exact count), but the array gets size 1 and consists garbage. I used this:
[MarshalAs(UnmanagedType.LPArray)]
BSICQAPI_User[] ppUsers //its a array of structs.
It doesnt matter if i do ref or not in the function header.
Does somone know how i can get the right parameter for BPSICQAPI_User **ppUsers ?
THX
sorry for my bad english
|
|
|
|
|
Try this:
[DllImport("whatever.dll")]
bool ICQAPICall_GetOnlineListDetails(
[MarshalAs(UnmanagedType.I4),Out]out int iCount,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0),Out]out BPSICQAPI_User[] ppUsers); Then, make sure that your BSICQAPI_User struct is defined to exactly match the structure in C++, meaning that you might even have to use the ManageAsAttribute on various fields in the struct. Since the OutAttribute is specified and the out keyword is used, then make sure you instantiate a large enough array before passing it to the method:
int count = 0;
BSICQAPI_User[] users = new BSICQAPI_User[40];
ICQAPICall_GetOnlineListDetails(out count, out users);
-----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-----
|
|
|
|