-
Jul 7th, 2021, 06:02 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] API's
Whenever I used an API in the past, someone has told me I needed one. Sometimes I got the code, sometimes, I figured out how to use the API, after it was given to me.
The question is, how would I know before asking when I would an API?
Thanks
-
Jul 7th, 2021, 08:35 PM
#2
Re: API's
Well you need to use APIs when you want to do something that the language you are using does not directly support or is to slow. There are many cases where you can use an API but you could also use native VB functions to do the task, There are other cases where you just can't do it without using an API be it the Windows API or a 3rd party API built specifically for interacting with the 3rd party software.
-
Jul 7th, 2021, 09:15 PM
#3
Re: API's
I assume when you say "API" you are talking about calling into non-ActiveX libraries, because even using a VB TextBox you make use of its API.
When you need something that VB's intrinsic statements, functions, controls, and no ActiveX library provides you may have to bite the bullet and make low level API calls. Sometimes even when there is a friendly wrapper library, you might need expanded access to the underlying lower-level library. So you use the low level API.
Or the issue might be performance, flexibility, etc.
Often there are COM libraries that lack a complete set of features to be ActiveX, such as a type library. Or an ActiveX library might contain class members that require an unsupported data type. You might have to call helper APIs to get access to those objects if you can't or don't want to write an appropriate type library.
Or you might be too cheap to acquire a license for a VB-friendly ActiveX library to do the job.
But all of this is pretty obvious, isn't it? Or are you asking about "web service" APIs?
-
Jul 7th, 2021, 09:20 PM
#4
Thread Starter
Fanatic Member
Re: API's
I am not looking at web service APIs. I am not looking for any specific API. I am trying to understand how I determine if I need an API, and if so, how I can find the appropriate one.
-
Jul 8th, 2021, 05:39 AM
#5
Hyperactive Member
Re: API's
Originally Posted by AccessShell
I am trying to understand how I determine if I need an API, and if so, how I can find the appropriate one.
A simple example: if you want to use MSComm to work with RS-232 over a three-wire line, you will face the problem of waiting for a client's response. Using Win32 API functions will solve this problem.
-
Jul 8th, 2021, 06:33 AM
#6
Re: API's
Huh?
The MSComm control works fine for that. You just have to Use The Events, Luke!
-
Jul 8th, 2021, 06:47 AM
#7
Re: API's
its basically all trial and error. You run into a problem, you search the web for answers. Most general things have been solved with examples by now. If you cant find a VB specific solution, then start searching how other languages have done it and that will show you which api to use. Dont worry about it to much. The api will reveal themselves to you as you need them. There are to many and they are to nuanced to just sit down and study to know off hand. Even once you know them, you will just keep an archive of code to do task X when you need it and not pay attention to the inner details after that.
-
Jul 8th, 2021, 08:03 AM
#8
Re: API's
Originally Posted by Argus19
A simple example: if you want to use MSComm to work with RS-232 over a three-wire line, you will face the problem of waiting for a client's response. Using Win32 API functions will solve this problem.
As stated above the MSComm control works fine if you use it right. I've did lots of serial comm stuff over the years and the only thing I needed to use something else on was when I needed to support various protocols such as x,y and z modem for file transfers. In those cases I use a different OCX that makes it easy to do those things. I have never found a need to use any low level API calls for serial comm apps.
-
Jul 8th, 2021, 08:08 AM
#9
Thread Starter
Fanatic Member
Re: API's
This was a hypothetical question. I don't need a specific API right now. I just wanted to find a better way of determining if I needed one.
-
Jul 8th, 2021, 08:18 AM
#10
Re: API's
Originally Posted by dilettante
Huh?
The MSComm control works fine for that. You just have to Use The Events, Luke!
I agree that MSComm control is one of the harder controls to emulate as it spawns a seprate worker thread to intercept input and raise events on the main thread which is very hard to do with win32 API and plain VB6.
With API calls one might try the better version of overlapped I/O on the serial ports which comes with another bag of problems with buggy drivers on these ubiquitous cheap USB-to-COM dongles. Then there is the Remote Desktop client which can "virtualize" local serial ports and bring one more bag of incompatibilities.
cheers,
</wqw>
-
Jul 8th, 2021, 09:13 AM
#11
Re: API's
You use API when you need to do something that the VB6 itself don't have buit-in support for.
How to know if you need an API? First you would need to know VB6 well, what it can do without resorting to APIs.
So, first you have to have a need, a need to do somehting. Then: can this be done with pure Vb6? If yes, then no API is needed. If no, then try to find how it can be done with APIs. How? Read a book, for example, Dan Applemans's Visual Basic Programmer's Guide to the Win32 Api or search the forum for how to do "your current need" for some solution that someone already posted.
You can also browse Allapi for studying different APIs, what they can do and how to use them, with examples.
-
Jul 8th, 2021, 10:41 AM
#12
Hyperactive Member
Re: API's
Originally Posted by wqweto
With API calls one might try the better version of overlapped I/O on the serial ports which comes with another bag of problems with buggy drivers on these ubiquitous cheap USB-to-COM dongles.
USB-to-RS-485 ? Connection timeout problems? Have to use a timer?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|