|
안녕하세요...
dll을 자주 사용을 안 하다 이번에 사용을 하게 되었는데,
전에는 문제가 없었는데 이번 dll에서는 문제가 있더군요.
음..그러니간 함수안에서 지역변수를 사용했을 경우에는 문제가 없는데,
함수에서 전역변수가 필요해서 전역변수를 선언하는 경우 변수가 작동을 안 하는군요.@@;;
그래서 이번에는 함수안에서 static으로 선언을 해주었는데도 역시나 작동을 안 하는군요...
이런 낭패가.............^^;(전에는 몰랐었음...;;; 지역변수를 사용한 함수만 사용했기 때문)
전혀 문제가 없을거라 생각을 했는데, 디버깅을 해보니 변수값이 전혀 움직이지 않고 작동도 안함..
dll에서는 전역변수나 함수안에서의 static변수사용할 때 다른 작업을 별도로 해주어야 하나요??
<NullRenderDll.h> 헤더 파일
extern "C" __declspec(dllexport) void OnVolume(float value);
extern "C" __declspec(dllexport) void OnBalance(float value);
extern "C" __declspec(dllexport) void SetSpeakerVolume(float fVolPercent);
extern "C" __declspec(dllexport) float GetSpeakerVolume();
extern "C" __declspec(dllexport) void Volume_OnOff();
//extern "C" __declspec(dllexport) void __fastcall GetMainVol();
<NullRenderDll.cpp> cpp파일
#include <vcl.h>
#include <windows.h>
//#include "NullRendering.h"
#include "NullRenderDll.h"
#include "math.h"
#include "DShow.h"
#include "windows.h"
#include "windowsx.h"
#include "stdio.h"
#include "assert.h"
#include "winbase.h"
//#include "winError.h"
#include "atlbase.h"
#include "atlconv.h"
#pragma hdrstop
#define VOLUME_FULL 0L
#define VOLUME_SILENCE -10000L
//---------------------------------------------------------------------------
// Important note about DLL memory management when your DLL uses the
// static version of the RunTime Library:
//
// If your DLL exports any functions that pass String objects (or structs/
// classes containing nested Strings) as parameter or function results,
// you will need to add the library MEMMGR.LIB to both the DLL project and
// any other projects that use the DLL. You will also need to use MEMMGR.LIB
// if any other projects which use the DLL will be performing new or delete
// operations on any non-TObject-derived classes which are exported from the
// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases,
// the file BORLNDMM.DLL should be deployed along with your DLL.
//
// To avoid using BORLNDMM.DLL, pass string information using "char *" or
// ShortString parameters.
//
// If your DLL uses the dynamic version of the RTL, you do not need to
// explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------
bool Volume__OnOff;<-----------------------------변수가 작동을 안 함..
float TOTAL;//대입값<-----------------------------변수가 작동을 안 함..
float m_fVolumePos;<-----------------------------변수가 작동을 안 함..
float m_fBalancePos;<-----------------------------변수가 작동을 안 함..
//함수 안에서 static으로 선언을 해도 역시나 작동을 안함...
IGraphBuilder *m_pGB;
IMediaControl *pMC;
IBasicVideo *pBV;
IMediaSeeking *pMS;
IBasicAudio *pBA;
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
void Volume_OnOff()
{
if(m_pGB == NULL)
return;// E_ABORT;
CComQIPtr<IBasicAudio> pBA(m_pGB);
if(!Volume__OnOff)
{
pBA->put_Volume(VOLUME_SILENCE);
Volume__OnOff=true;
}
else
{
pBA->put_Volume(VOLUME_FULL);
Volume__OnOff=false;
}
return;// S_OK;
}
................
|