Hello I am trying to write a simple sound recorder in a win32 forms application using visual c++ and am having problems linking to mmsystem.h I have the recorder working fine in a console application but cannot get it to work as a win32 app. when trying to reference the function waveInGetNumDevs() I get a linking error when trying to compile:
Error 1 error LNK2028: unresolved token (0A000031) "extern "C" unsigned int __stdcall waveInGetNumDevs(void)" (?waveInGetNumDevs@@$$J10YGIXZ) referenced in function "public: __clrcall record::Form1::Form1(void)" (??0Form1@record@@$$FQ$AAM@XZ) record.objrecord
I am assuming this has to do with managed and unmanaged code mixed together. So i made a header file referencing just the needed function and surrounded it with #pragma unmanaged and am compiling with /clr option.
Here is the header file:
Here is the code generating the error:Code:#sound.h #include "windows.h" #include "mmsystem.h" #pragma unmanaged WINMMAPI UINT WINAPI waveInGetNumDevs(void);
Any help on this matter would be appreciated. Thanks a lot.Code:#include "sound.h" #pragma managed namespace record { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public ref class Form1 : public System::Windows::Forms::Form { HWAVEIN hwin; MMRESULT result; int numDevices; public: Form1(void) { InitializeComponent(); numDevices = waveInGetNumDevs(); }
--koooee