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

GetNextWindow API in C#

I'm trying to call the GetNextWindow API function via C#.

I've tried two different definitions for it (both are similar), but i always
get the same error:

An unhandled exception of type 'System.EntryPointNotFoundException' occurred
in MsgTestCSharp.exe
Additional information: Unable to find an entry point named GetNextWindow in
DLL user32.dll.

The most recent way i tried was:

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr GetNextWindow(IntPtr hwnd, IntPtr wFlag);
what am i doing wrong here?

Thanks in advance,

-Tim
Nov 16 '05 #1
3 9930
Tim,

GetNextWindow isn't actually an API function, but rather, a macro that
just calls GetWindow. So you should define GetWindow, and call that. If
you really want to call a method named GetNextWindow, then you can define
the entry point, like this:

[DllImport("user32.dll", CharSet=CharSet.Auto, EntryPoint="GetWindow",
SetLastError=true)]
public static extern IntPtr GetNextWindow(
IntPtr hwnd,
[MarshalAs(UnmanagedType.U4)] int wFlag);

I changed the wFlag parameter because it would end up failing on 64-bit
systems.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tim Mulholland" <Ti***********@nospamaddress.com> wrote in message
news:e8**************@TK2MSFTNGP14.phx.gbl...
I'm trying to call the GetNextWindow API function via C#.

I've tried two different definitions for it (both are similar), but i
always
get the same error:

An unhandled exception of type 'System.EntryPointNotFoundException'
occurred
in MsgTestCSharp.exe
Additional information: Unable to find an entry point named GetNextWindow
in
DLL user32.dll.

The most recent way i tried was:

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr GetNextWindow(IntPtr hwnd, IntPtr wFlag);
what am i doing wrong here?

Thanks in advance,

-Tim

Nov 16 '05 #2
I dug into the .dll with depends and found that out for myself just a few
minutes ago.
I had read that a while back, but i thought it was the other way around (why
make a macro that has a longer name than the original?)

Thanks for the top on the one parameter.

-Tim

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:ee**************@TK2MSFTNGP11.phx.gbl...
Tim,

GetNextWindow isn't actually an API function, but rather, a macro that
just calls GetWindow. So you should define GetWindow, and call that. If
you really want to call a method named GetNextWindow, then you can define
the entry point, like this:

[DllImport("user32.dll", CharSet=CharSet.Auto, EntryPoint="GetWindow",
SetLastError=true)]
public static extern IntPtr GetNextWindow(
IntPtr hwnd,
[MarshalAs(UnmanagedType.U4)] int wFlag);

I changed the wFlag parameter because it would end up failing on 64-bit systems.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tim Mulholland" <Ti***********@nospamaddress.com> wrote in message
news:e8**************@TK2MSFTNGP14.phx.gbl...
I'm trying to call the GetNextWindow API function via C#.

I've tried two different definitions for it (both are similar), but i
always
get the same error:

An unhandled exception of type 'System.EntryPointNotFoundException'
occurred
in MsgTestCSharp.exe
Additional information: Unable to find an entry point named GetNextWindow in
DLL user32.dll.

The most recent way i tried was:

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr GetNextWindow(IntPtr hwnd, IntPtr wFlag);
what am i doing wrong here?

Thanks in advance,

-Tim


Nov 16 '05 #3
Tim,
(why make a macro that has a longer name than the original?)


It started out as a real function in the Win16 API. In Win32 it's a
macro mostly available for backward compatibility.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #4

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

Similar topics

1
by: Steve | last post by:
Hi, I'm coming back to VB for some work i need to do. Last I used was VB3 and it had a API call called 'getnextwindow'. It would take a window it found and goto the next one of the same type. ...
2
by: Steve | last post by:
i just posed asking about getnextwindow...i was able to find it but have another problem pwin = GetWinByClass(Text2.Text) bwin = FindWindowEx(pwin, ByVal 0&, Text5.Text, Text7.Text) nwin =...
11
by: Jozef | last post by:
I have some old code that I use from the Access 95 Developers handbook. The code works very well, with the exception that it doesn't seem to recognize wide screens, and sizes tab controls so that...
1
by: Linus Sylv?n | last post by:
Hi I'm trying to make a virtual keyboard and having problems with the focusing and seeing to that the keyboard is always on top. If I don't care about the keyboard being on top and use the...
9
by: Martin Ortiz | last post by:
I want to use the Win32 API function : SendMessageToDescendants I want to use it in a VB.Net app, but I have a few questions..... 1) Can one use Win32 API functions in VB.Net 2) Is doing so a...
6
by: Martijn Coppoolse | last post by:
Hello everyone, I've got two little apps which are able to create a window that displays something on the desktop, but are not clickable. Instead, when you click on the window, the item...
4
by: blah | last post by:
Hello everyone, Ive been trying to get my application to "click" on a button in another application using SendMessage, Ive gotten this far but Im not sure whats wrong with this code, here is the...
3
by: Hello everyone | last post by:
Hello everyone, Ive been trying to get this code to work for very long now, but I havent been able to catch the problem. Im trying to use the SendMessage method but when I execute the program...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.