Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C++ and Windows API 1

Status
Not open for further replies.
Mar 29, 1999
1
0
0
US
I want to use certain functions from the Windows API in C++. I am familiar on declaring the API in VB but not in C++. Can anyone give me an example of declaring and using the Windows API in C code.<br>
Thanks
 
It is not clear whether you want to use C++ or C but lets look at C++ first. In a non-MFC Windows application written in C++, all you have to do is include windows.h and call the API. For a MFC application you can pretty much do the same except when the API call you're making is from within a class which has a virtual member function (somewhere in it's inheritance tree) that has exactly the same name and signature as the API. In this case simply use the scope resolution operator :):) for the API call.<br>
For C programs, include windows.h and make the call (just as in the non-MFC, C++ case).<br>
The next thing you have to think about is the link phase - different SDK APIs exist in different dlls (kernel, GDI, user etc.). You usually don't have worry about which libs to link with if you use Devstudio (and the likes). If you need to explicitly add the libs then check the online documentation or MSDN to determine where the API needed can be found.<br>
<br>
I hope this answers your question.<br>
<br>
DMI
 
The answer DMI provided was useful, however I have a related question, I am building an interface to mysql with DevStudio, when I use the lib, Devstudio looks for libmysql.lib and libmysql.dll. When I add libmysql.dll to the path, listed in the settings/links/ it claims the dll is corrupt. I took the source and recomplied libmysql.c, and the bombs out on :<br>
<br>
include 'config - win32.h'<br>
<br>
Q: what is win32.h, if I am conpliing on a NT platform?<br>
Q: If I copy the libmysql.dll to the lib directory, would it get the same ' ..corrupt message' if the dll was not regersted?<br>
<br>
Thank you for any help you could provide.<br>
<br>
M. Higgins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top