473,799 Members | 3,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Interop question

When executing some win32 messages in c# I get unexpected results.
The following example is suppose to return the handle of an image in a
button control of another application but it return a negative
handle...is anybody know why it return an invalid handle like
"-989523277" ??

IntPtr ImageHandle =
Win32.SendMessa ge(Handle,BM_GE TIMAGE,IntPtr.Z ero,IntPtr.Zero );
MessageBox.Show (ImageHandle.To String());

Note : the third param is set to IMAGE_BITMAP (0); it return 0 if
the button contain no image.

Thanks...
Aug 22 '08
11 2354
It's _possible_ that if you describe what you're really trying to do here, *
*from the high-level goal perspective, ignoring completely any particular *
implementation details, someone could offer better advice.

Pete
I'm doing a tool like spy++. Win32 controls are interpreted (runtime
converted) as .net object
for example Win32 control properties are displayed in a managed
propertyGrid of my spy++ application just like any other .Net
control.

My question was about filling Button.Image in my property grid
(selectedObject is a button) when converting a Win32 control to a .net
control.

I was just wondering why WM_GETIMAGE return unusable image handle...
(never seen a negative handle since now) With your help I understand
that it return a negative unasable handle because it's in another
process.

I already use a dll and a windows hook to get things like
Button.ImageLis t with WM_GETIMAGELIST and will probably use the same
kind of code to get the image handle of WM_GETIMAGE from the other
process.

Pete : What you mean By malware-like techniques?? Is there any other
way to do this without hooking windows to inject a dll into the other
process???

Since you always trying to help me in different threads here , you now
know why i'm asking win32 to .net questions. :)
Aug 22 '08 #11
On Fri, 22 Aug 2008 14:41:00 -0700, michelqa <mi******@yahoo .cawrote:
[...]
I was just wondering why WM_GETIMAGE return unusable image handle...
(never seen a negative handle since now) With your help I understand
that it return a negative unasable handle because it's in another
process.
Just to clarify: the fact that the IntPtr appears as a negative number is
irrelevant. It would look that way (and does) in the process where it's
valid. The reason it's not usable is that it's relative to the process,
and your process isn't the one where the handle is defined.
I already use a dll and a windows hook to get things like
Button.ImageLis t with WM_GETIMAGELIST and will probably use the same
kind of code to get the image handle of WM_GETIMAGE from the other
process.

Pete : What you mean By malware-like techniques?? Is there any other
way to do this without hooking windows to inject a dll into the other
process???
A common malware technique is to take advantage of some vulnerability in a
process that fools it into loading the malware code into that process's
own address space and executing the code. Unless a process is
specifically designed to intentionally execute third-party code (e.g. has
some sort of plug-in interface), fooling it into running code is the only
alternative, and these techniques are all mainly used by malware, not by
legitimate applications.

Pete
Aug 22 '08 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1011
by: Le Thanh Thuan | last post by:
In my VB.Net project, I using Interop.Excel 11.0 (Excel 2003 I create Setup project in my computer, and then , I setup in another computer using Excel 2000 When I run my application, a error occur File or assembly name Interop.Excel, or one of its dependencies, was not found. File name"Interop.Excel"
1
2585
by: Bob N5 | last post by:
I am working on an application that uses interop to do some simple operations with both Excel and Word. I have most of functionality working, but ran into issues on making things work with both versions of office. My questions are: 1. What is the 'best' practice for building an application that will work with both versions of office? Do I need to have a separate build with different references for each? 2. Can I install interop...
20
3200
by: Razzie | last post by:
Hey all, I'm really going through a small hell right now - I've completely lost it :) I made a project, using two interop libraries from exchange (created them as in this msdn article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsmtps/html/writingmngsinks.asp). I set my project properties as 'Register as COM interop' to true, I can install it my project on my developement machine without a flaw. Great.
3
9457
by: ScottWPNY | last post by:
I am including a reference to ADOX in a C# project by doing the following: In Solution Explorer, right-click the References node and select Add Reference. On the COM tab, select Microsoft ADO Ext. 2.7 for DDL and Security, click Select to add it to the Selected Components, and then click OK. This creates a dll in my debug and release directory named Interop.ADOX.dll.
8
3426
by: Rob Edwards | last post by:
When trying to add the Microsoft CDO for Exchange Management Library (aka CDOEXM.dll) I receive the following message: "A reference to 'Microsoft CDO for Exchange Management Library' could not be added. Converting the type library to a .Net assembly failed. A depended type library 'CDO' could not be converted to a .NET assembly. A dependent type library 'ADODB' could not be converted to a .NET assembly. Item has already been added." ...
1
1974
by: Tom | last post by:
Hi, I have developed a VB.NET app that is referencing and using an old ActiveX component. When I add that reference to .NET, it of course generates an interop file. My question is: If I include the interop file with the application when deploying, do I need the original .dll object? For example, say I am including an old ActiveX component called OldActiveX.dll. .NET will generate an interop.OldActiveX.dll file. When I get ready to...
5
2143
by: Richard Lewis Haggard | last post by:
I am trying to create multi-dimensioned arrays in conventional ASP pages and pass these arrays as arguments to functions that are in a C# interop assembly. ASP complains because it doesn't recognize that the created array is the same as the declared interface argument. The C# function is expecting to receive a 2 dimensioned array and is declared like this: public object InteropFunc( string s1, object arValues ); What should the ASP...
5
1902
by: Yoavo | last post by:
Hi, In my application I have to use som external COM dll's. In the code: using MyDll when I build the project, I get (in addition to the .exe file) a Dll called Interop.MyDll.dll I want to send the .exe to the users without needing to send the dll. Is it possible to build my project without the accompanying dll ?
0
968
by: Ferd Biffle | last post by:
I am trying to convert an Add-In I wrote from .Net 1.1 (32 bit) to 2.0 on 64 bit XP. One of the vendor API Interop dll's that I am referencing is unavailable to my add-in. Looking at the references in the properties in Visual Studio 2005, I see that all of the other Interop dll's I am using are listed as COM, but the dll in question is shown as .Net. I have tried recreating the Interop using both the 32 bit and 64 bit
5
3276
by: John | last post by:
I would like to ask a question that is obvious to all people porting applications from the "traditional" C\VB6 interop scheme choosing C# vs VB.NET. We have a math library in C which ubiquitously takes a float* which represents an array of floats. If the memory is allocated by the client, in C# or VB.NET, I assume it must be "fixed" so that the GC does not move the pointer during the C algorithm. Given that we are choosing between C#...
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.