Thread: Programming APIs

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    183

    Programming APIs

    Hey guys. Just a few quick questions about application functionality. (Please move to appropriate board if necessary.) My first question is about the windows command prompt. I found myself wondering why console programs that are run from within the command prompt do not open in a new console window. I just performed a quick test of running a console application from within another console (via ShellExecuteEx()) and, sure enough, a new window was opened for the child application. I was just wondering how cmd.exe achieves the 'same-window' effect.

    My main question though, is about APIs. I think that's the correct term for what I'm refering to. If not, I apologise. A lot of professional programs (Firefox and IDA Pro spring to mind,) have extension capabilities. By this I mean that users can effectively write their own add-ons and they are incorporated into the main program. After much googling of APIs on the internet, I am still pretty stumped. I'm not after any code or anything, and I am certainly willing to do my own research, but I don't really know where to start. I was hoping that perhaps you guys could give me some key words to lookup to help me better understand the concept of extendable applications.

    Thanks for your time

  2. #2
    Registered User
    Join Date
    Jan 2011
    Posts
    31
    My understanding of APIs are that they let the user interact with the hardware. I've worked with DirectX D3D and OpenGL for drawing.

    Direct3D and OpenGL allows the user to use their libraries and send commands to the video card for rendering.

    My friend's definition :
    An interface that a user can use to request certain functions of the API's directed hardware

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Moved to Tech board.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    The reason a call to ShellExcecute() or ShellExcuteEx() create new console windows is that the new program being launched doesn't know the handle of the current shell window.

    You can also force your programs to open their own shells... but if you're going to go that far you might as well write a GUI mode program and have it done with.

    For the question about APIs... I'm thinking you're talking about custom window controls. Anyone can write a custom control. I've written a couple, myself. Basically it's just a window you have to draw yourself. It has a message queue, etc, just like any other windows program.

    If you're interested in API work (generally the closest to windows you're going to get) you should download the Software Development Kit (SDK)...

    Download details: Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1

    and familiarize yourself with the MSDN knowldege base...

    MSDN Library

    The SDK is a full disclosure of all windows system calls and MSDN has a wealth of programming information available. While you can view the SDK calls list online at MSDN the SDK also includes a mess of samples, debugging tools, a full set of windows headers and libraries, and the VC++ 2008 compiler.

    Don't even try to memorize or even remember this stuff --there's a ton of it-- just make sure you know how to look things up when you need them...

  5. #5
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    Quote Originally Posted by CommonTater View Post
    [...] The SDK is a full disclosure of all windows system calls [...]
    Are you sure? I haven't tested any of these, but here's a site devoted to undocumented(and by inclusion, undisclosed) Windows system calls: :: The Undocumented Functions by NTinternals ::

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by User Name: View Post
    Are you sure? I haven't tested any of these, but here's a site devoted to undocumented(and by inclusion, undisclosed) Windows system calls: :: The Undocumented Functions by NTinternals ::
    Yep, I'm sure... it's all the ones MS supports.

    Are there other things you can call? Of course there are... but there's no guarantee they will still be there in the next version... or after the next update for that matter.

    (and NO I am not letting that site install activex controls on my system)
    Last edited by CommonTater; 01-16-2011 at 03:00 PM.

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    183
    Thanks for your quick replies people!

    From what JohnLeeroy said, I know that 'API' is the wrong term for what I'm after. Cheers for the clarity. I think I'm actually asking about plugins or extensions. For instance, it is possible to extend the functionality of firefox because it supports user-made extensions or plugins. Some of these extensions may use custom window controls, if that's what you meant CommonTater?

    I was just wondering exactly how this support of additional components could be implimented. I wish to write a program that uses a default algorithm to sort data, but give users the option to write their own algorithms to use aswell. How do applications recognise extensions and communicate with them? Once again, I'm more than willing to research on my own, but a few helpful links or keywords would be nice Thankyou very much for the information on the command prompt, SDK and undocumented NT functions, I'm finding it very useful already.

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    I'm no genius on plugins... I'll let one of the others answer this one...

    But yes, extensible programs are possible in C and C++ ...

  9. #9
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Plugins, generally speaking, are dynamically loadable pieces of code and possibly other resources.

    The first decision you have to make is what language you expect plugins to be in. This strongly influences the packaging of said plugins.

    For example, Firefox really allows two kinds of plugins. First there's the classic plug-in like Flash. This is a native code plugin and thus written in any language that can be compiled to a DLL and access a C API. It is distributed as a dynamic library. Firefox provides a C API, the NPAPI, for the plugin to use.
    The other kind of plugin is the add-on. This is usually written in JavaScript, with resources in XUL, CSS, Translation DTD, plus images and other stuff. It is packaged as a zip archive. Firefox provides a JavaScript API (DOM and more) to these plugins. Add-ons can also contain native components that are specially registered so that the JavaScript parts can access them.

    C APIs are pretty easy to implement. They consist of a number of functions that are exported from some part of the program, usually a DLL, but if you are willing to go through the compatibility hassle, you can export them directly from the EXE.

    Other APIs depend on the language interpreter. Firefox uses a method specific to its own JavaScript implementation for exposing JS APIs. If you embed some other language interpreter - Lua, Python, ... - the method will differ. If you live in the Java or .Net worlds the method will be again different.

    Decide on a language and then design the API.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to copy binary files using Unix API's
    By rohan_ak1 in forum C Programming
    Replies: 25
    Last Post: 05-07-2008, 09:12 AM
  2. Any good windows system APIs?
    By taelmx in forum Windows Programming
    Replies: 2
    Last Post: 11-08-2006, 12:43 AM
  3. Other GUI API's that work in .NET?
    By subnet_rx in forum Tech Board
    Replies: 5
    Last Post: 09-02-2004, 03:23 PM
  4. CD Player using waveOutXXX APIs?
    By loobian in forum C++ Programming
    Replies: 6
    Last Post: 12-19-2003, 12:52 AM
  5. Those darn API's
    By Zahl in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 01-04-2003, 10:27 AM

Tags for this Thread