Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Pascal
Expertise: Beginner
Mar 18, 1999

Type-Declaration Characters

Question:
I'm having problems passing variables to an API function. I always receive a Type mismatch error. I reproduced the situation in Visual Basic and found that if I used type-declaration characters to declare the problem variables, they were compatible with the API function. So now, I have it working in Visual Basic, but not yet in Delphi. Are there type-declaration characters or something equivalent in Delphi? Here is a sample of my VB code:
'The following vars must be declared with a 
'type-declaration character, 'else Type mismatch '(why?...I have
a hunch that using 'As String'
'assigns a NULL value, where 'var$' actually 'assigns an empty
string "")
Dim desc$, dt$, con$, fn$, own$, v6$ 'strings
Dim fo%, mt% 'integers

Answer:
The problem doesn't lie in the API itself, but in Delphi's wrapper of the API call. What you need to do in addition to looking at the online help is to look at the Delphi source code for the call. Once you see how the call is prototyped, you can pass the appropriate types to it. It takes a lot of the guesswork out of calling API functions.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap