Where is "imports Win32"?

  • Thread starter Thread starter Marc Hillman
  • Start date Start date
M

Marc Hillman

Dumb question I know, but after 2 hours googling I give up.

What is the easiest/recommended way to access the Win32 API from VB Studio
Express? I assumed it would be a simple matter of Imports Win32, or
something similar and the whole API would be exposed. Surely I don't have to
Declare every API function I call individually? I just want to do things
like FindWindow, GetForegroundWindow and SendMessage. There are also a
gazillion constants like WM_CHAR et al, that I would have thought were
predefined somewhere.
 
Am 09.03.2010 11:45, schrieb Marc Hillman:
Dumb question I know, but after 2 hours googling I give up.

What is the easiest/recommended way to access the Win32 API from VB Studio
Express? I assumed it would be a simple matter of Imports Win32, or
something similar and the whole API would be exposed. Surely I don't have to
Declare every API function I call individually? I just want to do things
like FindWindow, GetForegroundWindow and SendMessage. There are also a
gazillion constants like WM_CHAR et al, that I would have thought were
predefined somewhere.

Nope. Dotnet was (also) meant to avoid API calls. But as it's not 100%
avoidable, you still have the possibility to declare and call what you need.

Anyway, in most applications you don't need hundreds of these declaration.
If you had a file or dll with all of them, it would increase application size
considerably (I guess). So I think it's better to collect them on your own
and paste in every application. Also see www.pinvoke.net (but I'd check each
declaration used) There are probably other collections out there in the
wide open web.
 
No, .NET expose most Win32 capabilities as classes, this is not a direct
copy of the underlying Win32 API. If you don't find a feature you need
you'll have to declare them (possibly wrapping this in a class).

Try for example :
http://www.pinvoke.net/

I assume this is to interact with an external Win32 app ?
 
Marc Hillman said:
Dumb question I know, but after 2 hours googling I give up.

What is the easiest/recommended way to access the Win32 API from VB Studio
Express? I assumed it would be a simple matter of Imports Win32, or
something similar and the whole API would be exposed. Surely I don't have to
Declare every API function I call individually? I just want to do things
like FindWindow, GetForegroundWindow and SendMessage. There are also a
gazillion constants like WM_CHAR et al, that I would have thought were
predefined somewhere.

.

There is a site, http://www.pinvoke.net, which has tools and signatures to
make this easier. The few times that I've needed these functions, that is
where I've looked.

Mike
 
Am 09.03.2010 14:06, schrieb Marc Hillman:
So how does one find the .dot version of (say) FindWindow?

The dotdot version? ;) Well, experience. If you know the
class library, you know (almost) where to look for it.
Or I try to imagine the dotnet name of the function and
use "symbol search" in the IDE. Or ask somebody.

With "FindWindow" I think it's not anywhere in the class lib.
Therefore I declare it. I guess it's not there because
dotnet is more like a high level application development
approach (I'm not going to discuss this). That also means
using the built-in IPC methods (which doesn't include finding a
window from a different application), and why find a window
in your own application? Did you lose it before? You work with
references, so...
Don't know if I made myself clear.

Also look at:
http://msdn.microsoft.com/en-us/library/aa302340.aspx

Unfortunatelly there doesn't seem to be an updated version.
 
Marc --

Am 09.03.2010 11:45, schrieb Marc Hillman:
What is the easiest/recommended way to access the Win32 API from VB
Studio Express? I assumed it would be a simple matter of Imports Win32,
or something similar and the whole API would be exposed. Surely I don't
have to Declare every API function I call individually? I just want to
do things like FindWindow, GetForegroundWindow and SendMessage. There
are also a gazillion constants like WM_CHAR et al, that I would have
thought were predefined somewhere.

This tool may help:

clrinterop - Release: PInvoke Interop Assistant
<URL:http://clrinterop.codeplex.com/releases/view/14120>
 
Back
Top