473,385 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Integrating Windows API into C# code

I have Windows API code which is written in C++.Sorry,if i'm wrong.How to integrate it into C# code.I mean how to make it work?This code must get the word under the mouse cursor in RichTextBox control.

[DllImport("user32")] public static extern int GetCursorPos(ref POINTAPI lpPoint)
[DllImport("user32")] public static extern int SendMessage(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As Integer)
[DllImport("user32")] public static extern int WindowFromPoint(int xPoint, int yPoint)

const object WM_GETTEXT = 13;
const object WM_GETTEXTLENGTH = 14;

POINTAPI P;
long lRet;
long hHandle;
string aText;
long lTextlen;
string aText;
lRet = GetCursorPos(P);
hHandle = WindowFromPoint(P.x, P.y);
lTextlen = SendMessage(hHandle, WM_GETTEXTLENGTH, 0, 0);
if (lTextlen)
{
if (lTextlen > 1024) lTextlen = 1024;
lTextlen += 1
aText = Space(lTextlen);
lRet = SendMessage(hHandle, WM_GETTEXT, lTextlen, aText);
aText = aText.Substring(lRet);
}
Aug 24 '07 #1
0 868

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Woodster | last post by:
I currently have some code for an application that is running on Win32. I have tried to keep anything not directly gui related as separate as possible for portability reasons, including file...
3
by: Sonoman | last post by:
Hi all: Is there a class or function that I could use to integrate? By integrating , I mean calculus integration. I need to get data from a sensor that gives me the acceleration of an object. In...
2
by: John Stockton | last post by:
Ok, I have a funky situation here. The client has an existing windows application that they want exposed via their c# asp.Net application. The windows app is not .Net based and we do not have the...
3
by: Lucas Tam | last post by:
Hi all, Assuming I've built a windows form application... how do I connect it to a web service? All the examples of web services I've seen pertain to stand alone applications. Basically,...
10
by: Lars Netzel | last post by:
Hi! I have a property of a Control (a button I'm making) that makes it possible for the user to choose what shape a button should have... Round, Square, Triangle... How do I in the designer...
4
by: karpagam | last post by:
Since WebServices are a standardized way to invoke a method of another application over the internet, is there a way to integrate two different applications running on different platforms (Say a...
0
by: Mark Harrison | last post by:
HOWTO: Integrating Posgresql queries into an event loop. Mark Harrison mh@pixar.com May 27, 2004 Problem ------- The commonly used postgresql APIs will block until completed.
1
by: Jeff | last post by:
....still new to VWeb .net 2005 wtih VB... ....having some problem integrating java script to open a second browser window with my VB code. The following line (in page-load) properly opens a new...
4
by: =?Utf-8?B?VGVycmFuY2U=?= | last post by:
I have a question about functionality I was wondering if anyone ever tried. Here is my problem/question. I'm currently in the motions of learning C# with that said I created a windows application...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.