Click to See Complete Forum and Search --> : Just don't get it
Japalo
Aug 15th, 2000, 01:55 AM
Im trying to learn api
declare function publicname lib "libname" _ <--I understand
Alias "alias" Byval variable as type <--- don't understand
can any help expain?
what do i treat the returned data as?
Sophtware
Aug 15th, 2000, 03:09 AM
Am new too api as well but ill give it a shot.
Ok the (ByVal As Variable as type) means
Whatever you set the variable in the type declaration like this
Public type Woah
Integer * 25 <--- thats the The value that the api uses
End Type
Hope i made sense.. :)
1) The libname is the library in which the API function is in.
2) ByVal simply means that you are passing a copy of the value. When using API's, always pass arguments with ByVal.
3) Most API's have a return value of 0 (if an error occured) or 1 (if it was a success). Others such as FindWindow will return important information, such as the handle of a window.
parksie
Aug 15th, 2000, 03:00 PM
The Alias keyword is very important for the Win32 API. Basically, it means that if you have:
Private Declare Function WindowsFunc Lib "kernel32" Alias "WindowsFuncA" () As Long
...then in the DLL, the function is called WindowsFuncA, but you would rather refer to it as WindowsFunc. Many functions in the API have two versions, an A version, and a W version. The 'A' is for ANSI (Windows 9x), and the 'W' is for Wide (Unicode on NT).
Paul Warren
Aug 16th, 2000, 05:48 AM
Alias is also important because many functions have names which are illegal in VB so you can provide one that's legal. For example it might be a reserved word or contain characters which can't be used ( such as starting with a _ ).
A really good place to look at these declarations is on the MSDN CD, under books. 'Hardcore VB' gives a thorough and clear explanation of how to create declarations from just the C export info. Well worth reading.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.