Solved

Problem calling API functions directly

Posted on 1997-10-31
3
216 Views
Last Modified: 2013-12-14
I am designing a user interface for Win 95 using Microsoft Visual C++ 5.0.  I have not been able to directly call an API function.  I have had no problem accessing them through the MFC library classes though.  For example, I used the CFileDialog class to implement a file open dialog box but when I tried calling the API function, GetOpenFileName() directly nothing happens during execution.  No compile or link error during build.  When I run the debugger and try to step into GetOpenFileName(), it was skipped over without even hitting the first internal line of code.  A call to GetOpenFileName() was in the assembly code when I checked.  Now, I need a simple audible ‘beep’ for my interface and I want to directly call another API function, Beep().  I haven’t found a MFC library class that encompasses Beep() so I am trying to call the API function directly.  Any ideas why I am having problems calling API functions directly?
0
Comment
Question by:chele
3 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
Comment Utility
If you're in the context of a CWnd-derived class's functions, then you will need to use :: (scope resolution operator) to use the global functions.

For example, use ::GetOpenFileName() to call the global version (API version).

If you want a beep, take a look at the online help for ::MessageBeep(). You can pass a parameter for what types of beep you want.

0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
Are you sure the API function is not executing?  Microsoft's debugger will not step into an API function.  This is to try to keep its workings secret (other debgers will, however.)  However the debugger will still run the function, it just won't step into it.  
0
 

Author Comment

by:chele
Comment Utility
Thanks again thui!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now