• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 375
  • Last Modified:

API's

Ok, I was looking thourgh all the API's calls and there is some interesting things like:
-------------------------------------
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
---------------------------------
how do I use these...all it says is what I posted above. But how do I call these in my programs?
0
sllyguy1
Asked:
sllyguy1
  • 4
  • 2
  • 2
  • +2
1 Solution
 
vettrangerCommented:
The followin article is a little dated, as it was written for the 16 bit API, but its as good an article as I've seen on using the INI file API calls.

http://support.microsoft.com/support/kb/articles/Q75/6/39.ASP

Just make sure that you use the 32 bit declares, and define any variables in this articles sample code as Long instead of integer. And if you have any problems with it, post it here and I'll help you with it, I've used all these calls quite a few times.

BTW, in VB6 you have the GetSetting and SaveSetting functions, which are superior to saving information in INI files.
0
 
sexmachineCommented:
Actully What he is looking for is how to load them into a program, he doesnt care about INI file he was using that as an example of what he meant!
0
 
sllyguy1Author Commented:
Some one tell me how to load an api thing. Thanks I used the INI one as an example.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
sllyguy1Author Commented:
Some one tell me how to load an api thing. Thanks I used the INI one as an example.
0
 
mark2150Commented:
Buy a copy of Dan Applemans book "Visual Basic Programmers Guide to the Win32 API". Cost is about $60US and comes with complete text & samples on CD. Worth every penny.

You put the DECLARE in your program in the (General) section. Then you call function just like any other:

CALL APIname(Param1,...)

Appleman's book has all the declares and stuff in cut & paste form so you can drop it into your program. Also has data type declarations and related stuff. Makes using them dead easy.

M
0
 
vettrangerCommented:
Well, the sample I provided also shows where to put declares and how to use them. You have to start with one, so why not the one he mentioned!
0
 
mark2150Commented:
There is only one API call I use regularly, the one for ExecCmd. Source on my web page - cut & paste and run!

www.cyberchute.com/rvbus/madmark

M
0
 
st_steveCommented:
APIs are difficult (and powerful) routines....they're stored mostly in DLL files and are called from an "entry point"...they're too difficult to describe in detail...you must have a good background in C/C++ since most of them are written in C.

If you're not a power user or a low-level system programmer, just use the available functions in VB or download a few shareware OCXes to plug into your VB code...I'm still having a hard time trying to understand some of the APIs....esp. the Systray API. Gives me a lot of problems! If you find anything useful, share it with me as well, ok?
0
 
vettrangerCommented:
The above synopsis of APIs is very misleading. Altho a few API calls are somewhat complicated, many are quite simple to use, and some are almost essential to use in VB programming.

Over the years, quite a few features that were built in to VB have been dropped because you're expected to use them from the API.

APIs are definitely for the use of EVERY VB programmer, not just power users.
0
 
vettrangerCommented:
And also, I'm going to relock this with a response to 'load an API thing', since we all seemed to let this slip by us.

To make an API function available to your VB program :

1. Make a module, or open an existing one.

2. select the General Declarations section of the module.

3. Cut and paste the Declare statement into it.

4. If the API uses and constants, or data structures, cut and paste the definitions for them into the General Declarations section as well.

If you follow the steps given in the article I posted for you, it takes you thru the process of placing API code in the right places, and implementing the call itself.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now