我怎么释放资源呢,我用的是ACM控件(acmdialog,acmwaveout,acmwavein)代码很简单如下
您能帮我看一下那地资源需要释放。如果有源码请发到zhuoyue_x@163.com一定给分。还可以
再加分。
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ACMDialog"
#pragma link "ACMWaveIn"
#pragma link "ACMWaveOut"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::IdUDPServer1UDPRead(TObject *Sender,
TStream *AData, TIdSocketHandle *ABinding)
{
/*
Pointer a;
a = new Pointer();
a = AllocMem(AData->Size);
AData->Read(a, AData->Size);
try{
ACMWaveOut1->PlayBack(a,AData->Size);
}__finally{
SysFreeMem(a);
}
*/
char* a;
a = new char[AData->Size];
AData->Read(a,AData->Size);
//播放
try{
ACMWaveOut1->PlayBack(a,AData->Size);
}__finally{
delete []a ;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
Pointer format;
//用户指定ACM格式
format = ACMDialog1->OpenDialog();
if (!format)
{
return;
}
IdUDPClient1->Active = true;
IdUDPServer1->Active = true;
//指定远程IP,该IP决定了UDP可以广播的网段
IdUDPClient1->Host = Edit1->Text;
//打开ACM输出
ACMWaveOut1->Open(PWaveFormatEx(format));
//打开ACM输入
ACMWaveIn1->Open(PWaveFormatEx(format));
BitBtn1->Enabled = false;
BitBtn2->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn2Click(TObject *Sender)
{
//结束ACM
ACMWaveIn1->Close();
ACMWaveOut1->Close();
//结束UDP
IdUDPClient1->Active = false;
IdUDPServer1->Active = false;
BitBtn1->Enabled = true;
BitBtn2->Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ACMWaveIn1Data(Pointer data, int size)
{
TMemoryStream *a;
//向流中写入数据
a = new TMemoryStream();
a->Write(data,size);
//发送
IdUDPClient1->SendBuffer(data,size);
a->Free();
}
//---------------------------------------------------------------------------