473,387 Members | 1,365 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,387 software developers and data experts.

GetCursorPos - PInvoke error!!

Hi!

I'm getting a PInvoke error while trying to execute the following code...
declaration:
Structure POINTAPI

Dim x As IntPtr

Dim y As IntPtr

End Structure

Private Declare Sub GetCursorPos Lib "User32" (ByVal lpPoint As POINTAPI)
usage:
Dim MouseLocation As New POINTAPI

GetCursorPos(MouseLocation)

Please help!

Thanks in advance,

Rajesh

Feb 10 '07 #1
8 6636
On Feb 6, 1:57 pm, "Rajesh Soni" <rajeshgs...@yahoo.comwrote:
Hi!

I'm getting a PInvoke error while trying to execute the following code...

declaration:
Structure POINTAPI

Dim x As IntPtr

Dim y As IntPtr

End Structure

Private Declare Sub GetCursorPos Lib "User32" (ByVal lpPoint As POINTAPI)

usage:
Dim MouseLocation As New POINTAPI

GetCursorPos(MouseLocation)

Please help!

Thanks in advance,

Rajesh
Structure PointAPI
Public x As Integer ' Int32 if you prefer
Publci y As Integer ' Int32 if you prefer
End Structure

Public Declare Function GetCursorPos Lib user(ByRef lpPoint As
PointAPI) As Boolean

--
Tom Shelton

Feb 10 '07 #2
On Feb 10, 2:31 pm, "Tom Shelton" <tom_shel...@comcast.netwrote:
On Feb 6, 1:57 pm, "Rajesh Soni" <rajeshgs...@yahoo.comwrote:


Hi!
I'm getting a PInvoke error while trying to execute the following code...
declaration:
Structure POINTAPI
Dim x As IntPtr
Dim y As IntPtr
End Structure
Private Declare Sub GetCursorPos Lib "User32" (ByVal lpPoint As POINTAPI)
usage:
Dim MouseLocation As New POINTAPI
GetCursorPos(MouseLocation)
Please help!
Thanks in advance,
Rajesh

Structure PointAPI
Public x As Integer ' Int32 if you prefer
Publci y As Integer ' Int32 if you prefer
End Structure

Public Declare Function GetCursorPos Lib user(ByRef lpPoint As
PointAPI) As Boolean
woops - hit send to soon...
Public Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As
PointAPI) As Boolean

--
Tom Shelton

Feb 10 '07 #3
Tom,

Thanks Tom, but unfortunately i'm getting the same error :(

A call to PInvoke function 'Form_Name_.Form1::GetCursorPos' has unbalanced
the stack. This is likely because the managed PInvoke signature does not
match the unmanaged target signature. Check that the calling convention and
parameters of the PInvoke signature match the target unmanaged signature.

- Rajesh

"Tom Shelton" <to*********@comcast.netwrote in message
news:11**********************@m58g2000cwm.googlegr oups.com...
On Feb 10, 2:31 pm, "Tom Shelton" <tom_shel...@comcast.netwrote:
>On Feb 6, 1:57 pm, "Rajesh Soni" <rajeshgs...@yahoo.comwrote:


Hi!
I'm getting a PInvoke error while trying to execute the following
code...
declaration:
Structure POINTAPI
Dim x As IntPtr
Dim y As IntPtr
End Structure
Private Declare Sub GetCursorPos Lib "User32" (ByVal lpPoint As
POINTAPI)
usage:
Dim MouseLocation As New POINTAPI
GetCursorPos(MouseLocation)
Please help!
Thanks in advance,
Rajesh

Structure PointAPI
Public x As Integer ' Int32 if you prefer
Publci y As Integer ' Int32 if you prefer
End Structure

Public Declare Function GetCursorPos Lib user(ByRef lpPoint As
PointAPI) As Boolean

woops - hit send to soon...
Public Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As
PointAPI) As Boolean

--
Tom Shelton


Feb 10 '07 #4
"Rajesh Soni" <ra*********@yahoo.comschrieb:
Private Declare Sub GetCursorPos Lib "User32" (ByVal lpPoint As POINTAPI)
In addition to the other replies: Why not use 'Cursor.Position'?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Feb 10 '07 #5
On Feb 10, 2:43 pm, "Rajesh Soni" <rajeshgs...@yahoo.comwrote:
Tom,

Thanks Tom, but unfortunately i'm getting the same error :(

A call to PInvoke function 'Form_Name_.Form1::GetCursorPos' has unbalanced
the stack. This is likely because the managed PInvoke signature does not
match the unmanaged target signature. Check that the calling convention and
parameters of the PInvoke signature match the target unmanaged signature.

- Rajesh

"Tom Shelton" <tom_shel...@comcast.netwrote in message

news:11**********************@m58g2000cwm.googlegr oups.com...
On Feb 10, 2:31 pm, "Tom Shelton" <tom_shel...@comcast.netwrote:
On Feb 6, 1:57 pm, "Rajesh Soni" <rajeshgs...@yahoo.comwrote:
Hi!
I'm getting a PInvoke error while trying to execute the following
code...
declaration:
Structure POINTAPI
Dim x As IntPtr
Dim y As IntPtr
End Structure
Private Declare Sub GetCursorPos Lib "User32" (ByVal lpPoint As
POINTAPI)
usage:
Dim MouseLocation As New POINTAPI
GetCursorPos(MouseLocation)
Please help!
Thanks in advance,
Rajesh
Structure PointAPI
Public x As Integer ' Int32 if you prefer
Publci y As Integer ' Int32 if you prefer
End Structure
Public Declare Function GetCursorPos Lib user(ByRef lpPoint As
PointAPI) As Boolean
woops - hit send to soon...
Public Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As
PointAPI) As Boolean
--
Tom Shelton- Hide quoted text -

- Show quoted text -
post your code. You have not declared the function correctly.

Feb 10 '07 #6
Hey Herfried!

Thanks for that, it WORKED!!

-Rajesh
"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
"Rajesh Soni" <ra*********@yahoo.comschrieb:
>Private Declare Sub GetCursorPos Lib "User32" (ByVal lpPoint As POINTAPI)

In addition to the other replies: Why not use 'Cursor.Position'?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Feb 10 '07 #7
On Feb 10, 2:43 pm, "Rajesh Soni" <rajeshgs...@yahoo.comwrote:
Tom,

Thanks Tom, but unfortunately i'm getting the same error :(
working code:

Option Explicit On
Option Strict On
Imports System.Runtime.InteropServices
Public Class Form1
Private Structure PointAPI
Public x As Integer
Public y As Integer
End Structure

Private Declare Function GetCursorPos Lib "user32" (ByRef lpPoint
As PointAPI) As Boolean

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim pt As PointAPI
If GetCursorPos(pt) Then
MessageBox.Show(String.Format("x={0}, y={1}", pt.x, pt.y))
End If
End Sub
End Class

--
Tom Shelton

Feb 10 '07 #8
Tom,

Thanks a ton!!!!

-Rajesh

"Tom Shelton" <to*********@comcast.netwrote in message
news:11**********************@m58g2000cwm.googlegr oups.com...
On Feb 10, 2:43 pm, "Rajesh Soni" <rajeshgs...@yahoo.comwrote:
>Tom,

Thanks Tom, but unfortunately i'm getting the same error :(

working code:

Option Explicit On
Option Strict On
Imports System.Runtime.InteropServices
Public Class Form1
Private Structure PointAPI
Public x As Integer
Public y As Integer
End Structure

Private Declare Function GetCursorPos Lib "user32" (ByRef lpPoint
As PointAPI) As Boolean

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim pt As PointAPI
If GetCursorPos(pt) Then
MessageBox.Show(String.Format("x={0}, y={1}", pt.x, pt.y))
End If
End Sub
End Class

--
Tom Shelton

Feb 10 '07 #9

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

Similar topics

4
by: Ted | last post by:
Is it possible to use mailslots in .NET using PInvoke? I have a VC++ 6.0 based app that creates and listens to a mailslot. I have a second VC++ 6.0 based app that opens the mailslot and writes...
3
by: msnews.microsoft.com | last post by:
Hi i am using User32.dll in Visual stdio 2005. public static extern long SetActiveWindow(long hwnd); public static extern long keybd_event(byte bVk, byte bScan, long dwFlags,
5
by: Pucca | last post by:
I'm trying to pinvoke a function in a C++ dll but I'm getting an error that entry point can not be located from my pinvoke code. Do I need to add any code to the C++ DLL to make the pinvoke? The...
0
by: ntm | last post by:
Hi all you good m8 I try to make my first small program in vb, but im not very succesfull :D (Im using Visual Studio 2005) Form my own program i will like to set focus on an other running...
1
by: Roy | last post by:
Have a dll that calls a com object. Can call dll from C program fine, can call dll from C# program in compact framework (i.e. CE/PPC devices), no problem. On XP devices when I pinvoke it gets...
14
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain...
1
by: Damjan Malis | last post by:
Hi guys... could anyone please help me with my problem getting mouse cursor position while desktop being locked (WIN + L). MSDN says: "The input desktop must be the current desktop when you...
1
by: keerthikarani | last post by:
hi, I m using the following code in vb.net, but it shows me some error, can u explain why this error occurs and how to rectify it, but the following code works fine in vb Private Declare...
6
by: Jajjo | last post by:
Hey there, I'm experimenting with GetCursorPos instead of "static_cast"ing the LOWORD and HIWORD params. This is because I want to work with positions relative to teh screen. Myt question is...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.