cj said:
Ok, that's more understandable than anything I've found.
I might pass on the API viewers for now as the pinvoke site seems to
give me the listing of what kind of APIs are available and whats in them
which appears to be way to much to hope to remember but at least I can
bookmark the page. I don't quite get the code project page except I saw
a mention of Win32API.txt and I found that on my pc and it also has the
SW_RESTORE in it. Why wouldn't MS provide the definitions of the SW_
constants in I guess a header file for VB? I keep seeing where I could
agree with C++ programmers that VB is a second rate language.
Regarding Win32API.txt: if you have this file, I would assume you have
the API Text Viewer installed. On my machine at work, it's under
Start-->Programs-->Microsoft Visual Studio 6.0-->Microsoft Visual
Studio 6.0 Enterprise Tools-->API Text Viewer.
Once you start it up, goto File-->Load Text File and select the
Win32API.txt file. Then you can use the Viewer to more easily navigate
through the stuff in the file. However, there is a caveat, which is
that the code you get from the API Viewer is VB6 code, not VB.NET code.
OTOH, for non-production code, I'd say it's pretty safe to use the VB6
declares in VB.NET without changing anything. For example, a Long and
an Int32 are technically equivalent and therefore safely
interchangeable in the context of API declarations; the distinction
between them is an abstract one that only the VB.NET compiler cares
about - an API function won't be able to tell the difference, because
at a lower-level there is no difference between how data of either type
is represented. In fact, all VB6 code that uses the API relies on this
fact (i.e. take pointers to void [void *] for example, they have to
passed as Longs in VB6 since VB6 doesn't have pointer types) - so I
see no real harm in using code written in VB6 into VB.NET when the code
is dealing with API calls. In VB.NET, the addition of new data types
such as Int32 allows a programmer to more correctly declare an API
function by using data types that more closely match the "real" data
types of the function's arguments, but it doesn't make the API function
work any better or any worse.
[snip]
Is there
a way in the Windows API to shutdown windows?
Yes. The .NET declaration is:
Private Declare Function ExitWindowsEx Lib "user32.dll" Alias
"ExitWindowsEx" ( _
ByVal uFlags As Int32, ByVal dwReserved As Int32 _
) As Boolean
Private Const EWX_SHUTDOWN As Int32 = 1
And to shut down Windows, the call is:
ExitWindowsEx(EWX_SHUTDOWN, 0)
But again, if you just declare this as the API Viewer declares it, with
everything as Long:
Private Declare Function ExitWindowsEx Lib "user32.dll" Alias
"ExitWindowsEx" ( _
ByVal uFlags As Long, ByVal dwReserved As Long _
) As Long
It will work just as good. As I said, Long and Int32 are *equivalent*
as far as API Declares go because they are both 32 bits wide on 32-bit
versions of Windows. As for Boolean and Long in the return values, it
actually doesn't matter if they are two different sizes - the data type
of the return value can be any type that occupies exactly 32 bits or
less, because of the way return values are handled at the machine-code
level. To sum up, it really, really does not matter which version you
use - whether it's the older VB6 Declare or the newer VB.NET Declare,
it makes no difference when you call the function.
Mike S