Archived

This topic is now archived and is closed to further replies.

Rnoodles

beep();

Recommended Posts

Hey. I have been trying to find out how to use the beep function. I know you can do cout<<(char)7; but it doesn''t work on all computers. Below is the code I am using but it generates a ton of errors! Could someone tell me my error or where I could find a tutorial on how to use the beep command. Thanks. (note my computer did not have beep.h so I found it online) run.cpp ------------------------- #include #include"beep.h" int main(){ beep(3000,1000); beep(900,1000); return 0; } beep.h -------------------------- // beep.h -- define interface for a trivial COM object // // This file must be preceeded by the following includes // #include <objbase.h> // defines IUnknown // #include <initguid.h> // enables extern for GUID definitions // // but with the second only in one file per .exe or .dll #ifndef _beep_h_ #define _beep_h_ class IBeep : public IUnknown { public: virtual HRESULT DoBeep(UINT uAlert )=0; // methods must be pure virtual }; typedef IBeep * LPBEEP; // MSFT convention // Global ID''s defined here: one for the class factory, second for object or interface DEFINE_GUID(CLSID_IBeep,0x83769260,0x13A0,0x1069,0xBF, 0x6D,0x08,0x00,0x17,0x01,0xF8,0x3E); DEFINE_GUID(IID_IBeep, 0x83769261,0x13A0,0x1069,0xBF, 0x6D,0x08,0x00,0x17,0x01,0xF8,0x3E); // corresponds to a registration file /* REGEDIT HKEY_CLASSES_ROOT\CLSID\{83769260-13A0-1069-BF6D-08001701F83E} = Beep Object HKEY_CLASSES_ROOT\CLSID\{83769260-13A0-1069-BF6D-08001701F83E}\InProcServer32 = BEEP.DLL HKEY_CLASSES_ROOT\INTERFACE\{83769261-13A0-1069-BF6D-08001701F83E} = IBeep */ #endif here are the errors ------------------------------ --------------------Configuration: sound - Win32 Debug-------------------- Compiling... run.cpp c:\matt\c++\home\sound\beep.h(12) : error C2504: ''IUnknown'' : base class undefined c:\matt\c++\home\sound\beep.h(15) : error C2146: syntax error : missing '';'' before identifier ''DoBeep'' c:\matt\c++\home\sound\beep.h(15) : error C2433: ''HRESULT'' : ''virtual'' not permitted on data declarations c:\matt\c++\home\sound\beep.h(15) : error C2501: ''HRESULT'' : missing storage-class or type specifiers c:\matt\c++\home\sound\beep.h(15) : error C2061: syntax error : identifier ''UINT'' c:\matt\c++\home\sound\beep.h(15) : error C2253: ''DoBeep'' : pure specifier only applies to virtual function - specifier ignored c:\matt\c++\home\sound\beep.h(23) : error C2065: ''CLSID_IBeep'' : undeclared identifier c:\matt\c++\home\sound\beep.h(24) : error C2501: ''DEFINE_GUID'' : missing storage-class or type specifiers c:\matt\c++\home\sound\beep.h(24) : error C2078: too many initializers c:\matt\c++\home\sound\beep.h(25) : error C2065: ''IID_IBeep'' : undeclared identifier c:\matt\c++\home\sound\beep.h(26) : error C2501: ''DEFINE_GUID'' : missing storage-class or type specifiers c:\matt\c++\home\sound\beep.h(26) : error C2374: ''DEFINE_GUID'' : redefinition; multiple initialization c:\matt\c++\home\sound\beep.h(23) : see declaration of ''DEFINE_GUID'' c:\matt\c++\home\sound\beep.h(26) : error C2078: too many initializers c:\matt\c++\home\sound\run.cpp(6) : error C2065: ''beep'' : undeclared identifier Error executing cl.exe. sound.exe - 14 error(s), 0 warning(s)

Share this post


Link to post
Share on other sites