Thanks! That did exactly what I needed it to! I did consider using this method, however all of my attempts failed and left me clueless. It seems that this attribute really makes the difference: InterfaceType(ComInterfaceType.InterfaceIsIUnknown) Without it, the program simply crashes when you try to use it. Also, I have been using type-casts where QueryInterface would be required. It also worked in this case: IHTMLElementRender render = (IHTMLElementRender)element; render.DrawToDc(hdc); Thanks again for your reply :) - Joe
joeyespo
Posts
-
Call function from pointer -
Call function from pointerHi, I've searched everywhere! Does anyone here know how to call a function from C# from an IntPtr? I know how to obtain the function pointer: IntPtr ptr = (typeof(SOMECLASS).GetMethod("SomeMethodName").MethodHandle.GetFunctionPointer()) Now I just need a way to call it .. The reason I need this is because in MSHTML, there is an interface called IHTMLElementRender, and the function 'DrawToDC' (useful for capturing HTML documents as an image) takes the argument HDC, but is implemented to take a reference variable of an unrelated structure. Therefore I need to call the function by the pointer, as in C++. Thanks! - Joe Esposito
-
Assembler GuidanceHi, [Not being a very compulsive user of the Code Project Forums, I wasn't exactly sure where to post this; so sorry ahead of time if it has no purpose being here] I have been searching for hours for some kind of assembler source code. I've been designing an translator for a personal project, but have absolutely no idea how to begin the code generation (or basically, the assembler). Had the project not required an assembler of it's own, I would simply use one that's already been developed. Unfortunately this is not the case. I have scanned the endless pages of instruction set manuals, but there I am unable to aquire the information of a program's architecture for the 80x86 machine. This is why source code of any kind would be a great learning tool, though being able to read from the right documents could be quite beneficial as well. If anyone here can lend some guidance, I would greatly appreciate it! Thanks, Joe
-
Marshal an object [] to ptrHi, Is there any painless way to marshal an object [] into a ptr? I'm writing a plugin wrapper and the object [] is a paramarray ['params'] that represents a structure in the plugin. I was wondering if there was an easy way to do this, similar to the Marshal.StructureToPtr() maybe .. Here's an example for clearification ..
The wrapper's function:
void MyPluginFunction (params object [] data) { // Convert information stored in 'data' into a ptr ptr = MarshalObjToPtr(data); PluginFunction(ptr); }
The plugin function to be called (written in C# for this example)void PluginFunction (IntPtr ptr) { myData = (MyStruct)Marshal.PtrToStructure(ptr); ... }
Now 'myData' now holds all info in ptr, but in MyStruct representation. NOTE: The plugin may not be written in C#, and that is why I would need is to be marshalled.
Using the wrapper would be as simple as:
MyPluginFunction(12, 8, "hello");
The above would map to the plugin's structure:private struct MyStruct { int a, b; string s; }
Thus allowing the above function's 'myData' to be as follows: myData.a = 12, myData.b = 8, myData.s = "hello"
Or if there's an easier way to do this, that could work too. Best regards, - Joe
-
CompilersThanks for the comment! :) I do, however, own that book already; but if I hadn't, then your reply would have been the very best advice given so far and would have been extremely helpful for me (though it still can be to anyone else who hasnt yet read it!) You see, I'm working on a very large project of my own involving compilers and translators, and was wondering if there was any more ideas/concepts and methods of the back-end and code generation. As of now, I'm experimenting with translating data from one format to another (which, in these experiments, isn't always going to be associated with computer languages). This is why I would like to have a look at some other methods out there, to see what other algorithms exist that just may be even the slightest more dynamic than what I know now .. Anyone know if any other [more dynamic] methods exist other than the common practice? Thanks! :)
-
CompilersHi, I was wondering if anybody knew anything about the back-end of a compiler. I have been looking everywhere for different code generation techniques and can't seem to find any reliable sources--all tutorials I found stop at parsing (which I am all too familiar with, now). All I really need is a few methods of implementation (or even a theory, if nothing else). Any info or links to 'programming compilers' articles would be most appriciated! Thanks!