|
I’m actually quite good at looking at x86 machine code and producing equivalent C++ code. It takes some time but it’s not impossible.
Steve
|
|
|
|
|
*grin* I know, but it's hardly trivial like reflector is.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have an application that needs to connect to a webserver and download some files. When there is no proxy it works great. The problem is when the users are using an automatic proxy detection script. Is there any way I can find out the IP address of the proxy server that this script is making me use at runtime. If I have the IP address of the server I can then create a WebProxy based on the IP address and port and either make the user login or try and add the URL of the web server to the ByPass list. Thanks for your help.
Matt
|
|
|
|
|
I have posted this question before but didn't post the code.
The thing is for some reason, i cannot programatically Insert new row or update the database. However, I could fill the dataset after manaually populating the database.
Could any help me. The permissions are set right and the folder that contains the database file is also writable.
thank you.
below is what i have
ProductItemDataSet = new DataSet.DatabaseDataSet.ProductItemTableDataTable();
DataSet.DatabaseDataSetTableAdapters.ProductItemTableTableAdapter ProdAdapter =
new DataSet.DatabaseDataSetTableAdapters.ProductItemTableTableAdapter();
ProdAdapter.Fill(ProductItemDataSet);
ProdAdapter.Insert("man", "mango", "mango tree", "");
The database is in project Dataset. And this code exist in a different project but references the Dataset project.
Nana
|
|
|
|
|
Hello to Nana
you must use this code in FormLoad event for fill dataset:
prodadapter.fill(productitemdataset);
and use this code for add a new row to db:
ProductItemdataset.(TableName).AddNew(TableName)Row(field1,...);
ProdAdapter.Update(ProductItemDataset);
Good Luck.
Editali (Alireza Loghmani)
|
|
|
|
|
Does anybody know how to get an IntPtr to the executable that contains a resource?
I am successfully getting the assembly containing the type (which I assume [because it is the assembly to which the resource was added] should contain the resource) by calling Assembly a = Assembly.GetAssembly( t ); but how do you get an IntPtr to the executable that contains the resource (which I assume should be this assembly)? I can get a ModuleHandle structure from the assembly; but there doesn't seem to be a way to get an IntPtr to the executable from the ModuleHandle structure:
Type t = this.GetType( );
Assembly a = Assembly.GetAssembly( t );
ModuleHandle mh = a.GetModule( "APC" ).ModuleHandle;
I can get an IntPtr from Process.GetCurrentProcess( ).Handle, but this handle value does not appear to be valid (if indeed the resource I've added to the .DLL assembly are there, as they otherwise appear to be there). In other words, the IntPtr handle returned by the call into GetCurrentProcess does not appear to identify the assembly to which the resource belongs, whereas the call into Assembly.GetAssembly does identify the assembly I want a handle to, but I haven't found what processes to use to get a handle to *that* assembly from the assembly instance:
String s = "MT_ConfirmREFRESH";
IntPtr h = Process.GetCurrentProcess( ).Handle;
try
{
Glyph1.GMap = Bitmap.FromResource( h, s );
}
catch
{
throw new Exception( "Bitmap resource " + s + " not found from process handle " + h.ToString( ) + "." );
}
Succeeding in this is vital to implementing Bitmap.FromResource( IntPtr hinstance, String bitmapName ). I haven't found any examples that don't call into unsafe/unmanaged code. This means nobody is successfully retrieving bitmap resources embedded into class libraries?
That's a bit hard to believe.
|
|
|
|
|
Try using
Assembly.GetExecutingAssembly();<br />
Assembly.GetManifestResourceStream();
they work for me.
led mike
|
|
|
|
|
THANKS, MIKE. I gotta run... but I'll give this a go!
|
|
|
|
|
No, my call to Assembly.GetAssembly( t ) gets the assembly. That isn't the problem. The problem is getting an IntPtr handle to the assembly.
Any ideas on that? Since I can identify the proper assembly with Assembly.GetAssembly( t ), and since my call to IntPtr h = Process.GetCurrentProcess( ).Handle does not (?) appear to be returning a valid IntPtr to the executable containing the resource (my assembly returned by GetAssembly( t)), I am hoping there is somehow a way to get the IntPtr from my GetAssembly( t ) result.
That seems straightforward, but perhaps another way is intended to be the process.
In any case, all reasonable suggestions are appreciated. I'm traveling in just a bit, but will return to the forum in a few days.
|
|
|
|
|
In other words, you can't do this, and there doesn't seem to be a way to cast or otherwise derive the IntPtr value so that you could do the equivalent of this:
Glyph1.GMap = Bitmap.FromResource( ( IntPtr )Assembly.GetAssembly( t ), s ); So the question remains, How do you get an IntPtr to an executable containing a resource?
|
|
|
|
|
I don't know what to say at this point. As far as I am aware I gave you a solution that works, in my experience, and you have not tried it.
led mike
|
|
|
|
|
No, I tried it:
Glyph1.GMap = Bitmap.FromResource( ( IntPtr )Assembly.GetExecutingAssembly( ), s ); FromResource requires an IntPtr. As I indicated in my question, I need an IntPtr to the executable containing the resource. According to documentation, what you need to do to get *that* assembly is:
Type t = this.GetType( );
Assembly a = Assembly.GetAssembly( t );
This gets the assembly. The problem is, getting an IntPtr hinstance pointing to the assembly from the assembly.
Are you saying that you can get an IntPtr from your calls, because I don't see that in your answer?
|
|
|
|
|
mike montagne wrote: Glyph1.GMap = Bitmap.FromResource( ( IntPtr )Assembly.GetExecutingAssembly( ), s );
umm that's not what I told you to do. Perhaps you should go back and read my post.
led mike
|
|
|
|
|
This is just one permutation of what I tried with GetExecutingAssembly( ). If what you're intimating is that I need to try Assembly.GetManifestResourceStream() to retrieve the bitmaps so they can be assigned to my properties, I'll have to explore that later (?). I'm late to hit the road, but thanks so much for trying to set me straight on this. I'll get around to it as soon as I can.
|
|
|
|
|
mike montagne wrote: If what you're intimating is that I need to try Assembly.GetManifestResourceStream()
intimating? Since this is a forum based conversation I don't know how more clearly to state it than putting it directly in the post which I did.
led mike
|
|
|
|
|
In other words, we can get so far as acquiring a "ModuleHandle" from GetExecutingAssembly -- but I can do this with GetAssembly as well:
Assembly.GetExecutingAssembly( ).GetModule( "APC" ).ModuleHandle; ModuleHandle however is a struct with no field or conversion method which converts to an IntPtr to the instance of the assembly. That's the missing piece: How to get an IntPtr from the assembly, or something else, which identifies the executable containing the resource.
GetExecutingAssembly just looks like another course to the same dead end to me, unless we can get that IntPtr somehow.
But thanks for the try!
m
|
|
|
|
|
i guess you are confusing managed and unmanaged resources.
try using reflector to see whether it is a .net managed resource.
|
|
|
|
|
No, my resource is managed. I've added many bitmaps to my class library DLL by the visual process, Project.Add... Existing file...
Determining whether it is a managed resource is not the problem. The DLL is loaded by a test application, using the classes as they would typically be deployed. The problem is for the class, when it is in the test application (exe), to assign the bitmap resources to property, preferably with the Bitmap.FromResource( IntPtr hinstance, String bitmapName ) method.
|
|
|
|
|
|
Whoa. Jumps out and grabs you when it's in Bold!
I guess I need to learn to *read*! I suppose I was so intent on loading and embedded resource I just assumed this was the method (what other method is there?). So this *does* require calling into LoadLibrary to get the hinstance.
I'm going to have to look around to see what method to use to retrieve my managed resources, because that's the way I want to do it. I hope that isn't some odd implementation of "FromFile", even as the resources are managed -- maybe so?
|
|
|
|
|
mike montagne wrote: I'm going to have to look around to see what method to use to retrieve my managed resources
In fact it's rather easy. Just use the Windows Forms designer and assign an image (e.g. to a PictureBox).
Then take a look at the MyForm.Designer.cs file and see the designer-generated code that loads from the resource.
Adapt it and do it in a similar way.
|
|
|
|
|
|
|
Hi,
I need to create a mouse dragbox type of event, much like when you click and drag the mouse on the desktop, it creates the dotted line "box".
Does anyone know of any articles on how to do this?, i've thought of listening to the mouse click/move event and then drawing a rectangle from the posistions, but it would be much easier if there was a inbuilt event.
Regards,
Gareth.
|
|
|
|
|
gareth111 wrote: Does anyone know of any articles on how to do this?
Ever heard of Google[^] ?
led mike
|
|
|
|