Re: How to find those constants for a API Declare




"simon" <spainabc@xxxxxxxxx> wrote in message
news:1174506035.900968.205310@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello all friends. I am a VB-API beginner. I want to know hoe to find
its constants for a API Declare. For example:
When we declare a function:
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias
"RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String,
phkResult As Long) As Long

Const ERROR_SUCCESS = 0&
Const ERROR_BADDB = 1009&
Const ERROR_BADKEY = 1010&
Const ERROR_CANTOPEN = 1011&
Const ERROR_CANTREAD = 1012&
Const ERROR_CANTWRITE = 1013&
Const ERROR_REGISTRY_RECOVERED = 1014&
Const ERROR_REGISTRY_CORRUPT = 1015&
Const ERROR_REGISTRY_IO_FAILED = 1016&
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002

The questions are:
1. Why we just make those constants in the code?
2. What is relevance with those constants and this API function?
3. How can I find which constants will be used in a API function?
4. I´ve heard that in the C++ head file (.h file) can be found this
relation, but I don´t know hoe to find it yet.
5. Do you have any tools to refer it? The VB API viewer can find those
Declares, but I can´t find each API will use which constants.
-------------------------

Most of your questions can be answered by consulting the Platform SDK, but I
don't understand #1. The Platform SDK is the documentation for programming
in Windows. There are actually many SDKs, each for a specific topic. For
example, there's a DirectX SDK, Windows Media SDK, Windows Installer SDK,
etc. These are all available online and all can also be downloaded for local
installation on your computer (most of them free downloads, but a few SDKs
require an MSDN subscription).

Here's a link to the online documentation for RegCreateKey:

http://msdn2.microsoft.com/en-us/library/ms724842.aspx


You frequently have to go to other "pages" for more information and
sometimes even do more than that. For example, the docs state the function
returns ERROR_SUCCESS if successful and that if if fails, it returns a
non-zero error code defined in winerror.h. So you need to have winerror.h
and open it up and then really just look through it. It's harder for VB
programmers because the Platform SDK (and most SDKs) are documented for
C/C++ programmers.

Another thing...at the bottom of the documentation, there will be
information that tells you what Windows platforms support the function, the
library which exports the function, and the header file(s).

--
Mike
Microsoft Visual Basic MVP



.



Relevant Pages

  • How to find those constants for a API Declare
    ... its constants for a API Declare. ... Const ERROR_BADDB = 1009& ... What is relevance with those constants and this API function? ... How can I find which constants will be used in a API function? ...
    (microsoft.public.vb.winapi)
  • How to find those constants for a API Declare
    ... its constants for a API Declare. ... Const ERROR_BADDB = 1009& ... What is relevance with those constants and this API function? ... How can I find which constants will be used in a API function? ...
    (comp.lang.basic.visual.misc)
  • Re: How to find those constants for a API Declare
    ... its constants for a API Declare. ... "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, ... Const ERROR_BADDB = 1009& ... What is relevance with those constants and this API function? ...
    (comp.lang.basic.visual.misc)
  • Re: How to use WM5 SDK
    ... When I started using it's API, it always said the function call has not been ... SDK can meet my target. ... Since SDK hasn't mentioned how to declare a function, ... Playsound isn't part of the DotNet framework I think, ...
    (microsoft.public.pocketpc.developer)
  • Re: How to use WM5 SDK
    ... In the WM50 SDK help you can find which file to include in your source code ... When I started using it's API, it always said the function call has not ... SDK can meet my target. ... Since SDK hasn't mentioned how to declare a function, ...
    (microsoft.public.pocketpc.developer)