PDA

Click to See Complete Forum and Search --> : Data type in API calls.


gvphubli
Aug 2nd, 2001, 04:01 AM
Hi experts,

------------------------------
Public Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Long) As Long
------------------------------

here they use data type Long for hwnd if we change this to some other data type like byte and integer will the program shutdown.

And how should I ensure that the existing API declarations in the project are correct...


With warm rgds.
Girish Patil

crispin
Aug 2nd, 2001, 05:36 AM
DO NOT EVER change the data type, it will fail, and quite possibly crash. read MDSN and look at the function prototypes to study how to call the API routines, or look at sites like www.allapi.net

Megatron
Aug 2nd, 2001, 08:44 AM
If you know what you're doing that it's okay to change the datatypes around. For example, some prefer that wParam and lParam should be declared as Any.

A hWnd is really a datatype of HWND in C++, but you can go even lower, and find out that it's really an unsigned int. But VB doesn't support unsigned integers, so you have declare everything as Long.

gvphubli
Aug 2nd, 2001, 09:27 PM
Thanks for Ur early replies VB buddies..

ZanM
Aug 6th, 2001, 12:37 PM
The interesting thing about C++\Visual C++ is that MS has gone and added all these Data masks using Define hWnd is a long, wParam is a long, lParam is also a long but MS uses these Data masks for special types of information like a windows handle or a type of parameter in C++ a string is even a long in truth it's complecated stuff O'reilly has a very good book on the matter that if you read it three or four times makes since to us dumb vb programmers Win32 API for Visual Basic Programmer I think is the name link to book (http://www.oreilly.com/catalog/win32api/)