Vcoderz Community

Vcoderz Community (http://forum.vcoderz.com/index.php)
-   E-Learning Center (http://forum.vcoderz.com/forumdisplay.php?f=33)
-   -   Free Patriotic Movement Tone In C++ (http://forum.vcoderz.com/showthread.php?t=14430)

Google 01-11-2009 06:06 PM

Free Patriotic Movement Tone In C++
 
In my free time, I coded this small program that generates the FPM tone using the beep() function. This is the code:

Code:

//Free Patriotic Movement Tone By Edgard Chammas
#include <windows.h>
#include <time.h>

void sleep(unsigned int mseconds);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)

{
        Beep( 750, 200);
        Beep( 750, 200);
        Beep( 750, 200);
        sleep(100);
        Beep( 750, 400);
        sleep(50);
        Beep( 750, 500);
        sleep(200);
        Beep( 750, 300);
        Beep( 750, 300);
        Beep( 750, 300);

    return 0;
}

void sleep(unsigned int mseconds)                               
{
    clock_t goal = mseconds + clock();
    while (goal > clock());
}

Now your PC can be upgraded to support GMA! :p

Note: The compiled executable file is here <> in case you don't have a compiler...


samrieh 01-11-2009 10:41 PM

Re: Free Patriotic Movement Tone In C++
 
sorry because I dont know in the computer stuff, so what do we do in order to get the tone for that?

Google 01-11-2009 11:12 PM

Re: Free Patriotic Movement Tone In C++
 
Quote:

Originally Posted by samrieh (Post 167517)
sorry because I dont know in the computer stuff, so what do we do in order to get the tone for that?

It seems that you didn't download the zip file containing the program...
This is the link:
http://www.4shared.com/file/80106952/f080bb5f/FPM.html

Edit:
You can put the FPM.exe in a static place and make it run every time you logon to your user by this batch file:

Code:

@ECHO OFF
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /V "FPM" /D "C:\LOCATION_ON_THE_HARD_DISK\FPM.exe" /F

Save the code above as whatever.bat and run it once (you can delete it after)...

Tawa 01-11-2009 11:13 PM

Re: Free Patriotic Movement Tone In C++
 
It Didn't Work For Me, I Downloaded The Compiled File You Uploaded, And I Hear Nothing :p

I Am Using Visual C++ 2008, You Have To Add #include <stdafx.h> As A PreCompiler Library, I Don't Know Why Though.
And The:
int
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) Didn't Work For Me, I Get This:
Code:


1>Linking...
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Studies\C++ Projects\Test\Debug\Test.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Studies\C++ Projects\Test\Test\Debug\BuildLog.htm"
1>Test - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



I Tried The int main(void), It Worked.

Any Idea?

Malek 01-11-2009 11:18 PM

Re: Free Patriotic Movement Tone In C++
 
I'm using Visual C++ 2005, and i got this :

Code:

1>Compiling...
1>Test.cpp
1>.\Test.cpp(2) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
1>Build log was saved at "file://e:\Documents\Visual Studio 2005\Projects\Test\Test\Debug\BuildLog.htm"
1>Test - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Google 01-11-2009 11:38 PM

Re: Free Patriotic Movement Tone In C++
 
@Tawa
This is a windows 32-bit application and not a console application
To solve your problem, you either have to make a win32 project and put the code in, OR JUST create the cpp file and then in microsoft visual c++ go:
Project > Settings
In the C/C++ tab change the preprocessor definitions from WIN32,_DEBUG,_CONSOLE,_MBCS to WIN32, _DEBUG,_WINDOWS
In the Link tab change /subsystem:console in the project options to /subsystem:windows
And this will solve the problem.

@Malek
You have to download and install the SDK platform. It is not included by default in VC2005. That's why the compiler cannot find that header file.
Edit: If you want, download windows.h from the internet and put it in the libraries directory.


By the way, I'm using visual c++ 6.0 :p

Tawa 01-12-2009 12:01 AM

Re: Free Patriotic Movement Tone In C++
 
Lol, I Did Man, Nothing Shows Up, And I Hear Nothing :p

Google 01-12-2009 12:25 AM

Re: Free Patriotic Movement Tone In C++
 
1- I'm glad to hear that the code is compiled with you! :p
2- nothing is supposed to show up unless you do it like you did it before (console mode, with int main() instead of int WINAPI WinMain... )

3- Now we come to the more interesting part that your PC "hane" and does not beep :p / well it is either your PC's internal speaker is damaged or simply your ears are damaged :p
The beep sound volume depends on each PC...



Tawa 01-12-2009 12:35 AM

Re: Free Patriotic Movement Tone In C++
 
I Think My Laptop Doesn't Have An Internal Speaker.

And I Don't Think It's Damaged :p Cause I Never Heard A Beep From An Internal Speaker. And The Laptop Is Still Pretty New.


All times are GMT +1. The time now is 07:21 AM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger