Thread: hardware access

  1. #1
    Registered User krishnapollu's Avatar
    Join Date
    Dec 2010
    Location
    KERALA
    Posts
    29

    hardware access

    hi guys, i wanted to know whether it is possible to access the hardware unit (say, speaker) using a c program. And if so, how?

    I google'd, but did not get an apt answer. Help me pls..

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    It depends on your OS and compiler, and possibly how much you feel like playing with assembly (or some library that is already written for you). If YOU want to access it directly, without libraries someone else has written, then it's going to be entirely OS, compiler, and likely, assembly (ASM) specific work.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by krishnapollu View Post
    hi guys, i wanted to know whether it is possible to access the hardware unit (say, speaker) using a c program. And if so, how?

    I google'd, but did not get an apt answer. Help me pls..
    Most operating systems do not allow direct hardware access.
    You either go through the drivers or not at all...

    And yes, this makes perfect sense when you consider what could be done if someone had direct access to, say, your hard disk...

    If you want to make noises out of your speaker...
    Code:
    #include <windows.h>
    
    int main (void)
      { Beep(500,300);
         Sleep(200);
         Beep(1000,300);
         Sleep(200);
         Beep(400,300); 
    
         return 0;}
    If you're looking to play wave sounds... Look at the PlaySound() API call.
    If your looking to play MP3s or such ... Look at MCI and Direct Sound APIs.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Order of access labels in class definition
    By Mario F. in forum C++ Programming
    Replies: 10
    Last Post: 06-16-2006, 07:13 AM
  2. Segmentation Fault - Trying to access parallel port
    By tvsinesperanto in forum C Programming
    Replies: 3
    Last Post: 05-24-2006, 03:28 AM
  3. How to access struct fields in array
    By dv007 in forum C++ Programming
    Replies: 3
    Last Post: 01-18-2006, 09:51 AM
  4. accessing a database made in Access..
    By willc0de4food in forum Windows Programming
    Replies: 4
    Last Post: 10-10-2005, 07:40 PM
  5. FtpFileFind access violation with MS VC++ 6.0
    By earth_angel in forum C++ Programming
    Replies: 3
    Last Post: 09-22-2005, 07:02 PM