diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 166208aa..cbc4cf68 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -53,10 +53,4 @@ endif () target_link_libraries(xege INTERFACE gdiplus INTERFACE gdi32 - INTERFACE imm32 - INTERFACE msimg32 - INTERFACE ole32 - INTERFACE oleaut32 - INTERFACE uuid - INTERFACE winmm ) diff --git a/src/ege_common.h b/src/ege_common.h index 46ed6bf9..c28f713b 100644 --- a/src/ege_common.h +++ b/src/ege_common.h @@ -12,6 +12,7 @@ #include "ege_math.h" #include "ege_time.h" #include "ege_graph.h" +#include "ege_dllimport.h" #include "type.h" #include "utils.h" diff --git a/src/ege_dllimport.cpp b/src/ege_dllimport.cpp new file mode 100644 index 00000000..89a7150c --- /dev/null +++ b/src/ege_dllimport.cpp @@ -0,0 +1,314 @@ +#include "ege_dllimport.h" + +#include +#include +#include + + +#define LOG(logtext) \ +do \ +{ \ + fprintf(stderr, "%s\n", (logtext)); \ +} while (0) + +#define LOG_IF(express, logtext) \ +do \ +{ \ + if (!!(express)) { \ + LOG(logtext); \ + } \ +} while (0) + +namespace dll +{ + // ----------------------------- imm32.dll ------------------------------------ + static HMODULE imm32Dll; + static HIMC (*func_ImmGetContext)(HWND); + static BOOL (*func_ImmSetCompositionWindow)(HIMC , LPCOMPOSITIONFORM); + + static void initImm32Dll() + { + imm32Dll = NULL; + func_ImmGetContext = NULL; + func_ImmSetCompositionWindow = NULL; + } + + static bool loadImm32Dll() + { + if(imm32Dll == NULL) { + imm32Dll = LoadLibraryA("imm32.dll"); + if (imm32Dll == NULL) { + LOG("ege error: Failed to load imm32.dll."); + return false; + } + } + + // ImmGetContext + if (func_ImmGetContext == NULL) { + typedef HIMC (*ImmGetContext_FuncType)(HWND); + func_ImmGetContext = (ImmGetContext_FuncType)GetProcAddress(imm32Dll, "ImmGetContext"); + LOG_IF(func_ImmGetContext == NULL,"ege error: The 'ImmGetContext' function cannot be found from the imm32.dll."); + } + + // ImmSetCompositionWindow + if (func_ImmSetCompositionWindow == NULL) { + typedef BOOL (*ImmSetCompositionWindow_FuncType)(HIMC, LPCOMPOSITIONFORM); + func_ImmSetCompositionWindow = (ImmSetCompositionWindow_FuncType)GetProcAddress(imm32Dll, "ImmSetCompositionWindow"); + LOG_IF(func_ImmSetCompositionWindow == NULL, "ege error: The 'ImmSetCompositionWindow' function cannot be found from the imm32.dll."); + } + + return func_ImmGetContext && func_ImmSetCompositionWindow; + } + + HIMC ImmGetContext(HWND hwnd) + { + if (func_ImmGetContext) { + return func_ImmGetContext(hwnd); + } + return NULL; + } + + BOOL ImmSetCompositionWindow(HIMC imc, LPCOMPOSITIONFORM compositionForm) + { + if (func_ImmSetCompositionWindow) { + return func_ImmSetCompositionWindow(imc, compositionForm); + } + + return FALSE; + } + + // ----------------------------- msimg32.dll ---------------------------------- + static HMODULE msimg32Dll; + static BOOL (*func_AlphaBlend)(HDC hdcDest,int xoriginDest,int yoriginDest,int wDest,int hDest,HDC hdcSrc,int xoriginSrc,int yoriginSrc,int wSrc,int hSrc,BLENDFUNCTION ftn); + static BOOL (*func_GradientFill)(HDC hdc, PTRIVERTEX pVertex, ULONG nVertex, PVOID pMesh, ULONG nMesh, ULONG ulMode); + + static void initMsimg32Dll() + { + msimg32Dll = NULL; + func_AlphaBlend = NULL; + func_GradientFill = NULL; + } + + static bool loadMsimg32Dll() + { + // -- msimg32.dll -- + if (msimg32Dll == NULL) { + msimg32Dll = LoadLibraryA("msimg32.dll"); + if (msimg32Dll == NULL) { + LOG("ege error: Failed to load msimg32.dll."); + return false; + } + } + + // AlphaBlend + if (func_AlphaBlend == NULL) { + typedef BOOL (*AlphaBlend_FuncType)(HDC hdcDest,int xoriginDest,int yoriginDest,int wDest,int hDest,HDC hdcSrc,int xoriginSrc,int yoriginSrc,int wSrc,int hSrc,BLENDFUNCTION ftn); + func_AlphaBlend = (AlphaBlend_FuncType)GetProcAddress(msimg32Dll, "AlphaBlend"); + LOG_IF(func_AlphaBlend == NULL,"ege error: The 'AlphaBlend' function cannot be found from the msimg32.dll."); + } + + // GradientFill + if (func_GradientFill == NULL) { + typedef BOOL (*GradientFill_FuncType)(HDC hdc, PTRIVERTEX pVertex, ULONG nVertex, PVOID pMesh, ULONG nMesh, ULONG ulMode); + func_GradientFill = (GradientFill_FuncType)GetProcAddress(msimg32Dll, "GradientFill"); + LOG_IF(func_GradientFill == NULL, "ege error: The 'GradientFill' function cannot be found from the msimg32.dll."); + } + + return func_AlphaBlend && func_GradientFill; + } + + BOOL AlphaBlend(HDC hdcDest,int xoriginDest,int yoriginDest,int wDest,int hDest,HDC hdcSrc,int xoriginSrc,int yoriginSrc,int wSrc,int hSrc,BLENDFUNCTION ftn) + { + if (func_AlphaBlend) { + return func_AlphaBlend(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, ftn); + } + return FALSE; + } + + BOOL GradientFill(HDC hdc, PTRIVERTEX pVertex, ULONG nVertex, PVOID pMesh, ULONG nMesh, ULONG ulMode) + { + if(func_GradientFill) { + return func_GradientFill(hdc, pVertex, nVertex, pMesh, nMesh, ulMode); + } + return FALSE; + } + + // --------------------------------- winmm.dll ------------------------------------------- + static HMODULE winmmDll; + static MMRESULT (*func_timeBeginPeriod)(UINT uPeriod); + static MMRESULT (*func_timeEndPeriod)(UINT uPeriod); + static MMRESULT (*func_timeSetEvent)(UINT uDelay,UINT uResolution,LPTIMECALLBACK fptc,DWORD_PTR dwUser,UINT fuEvent); + static MMRESULT (*func_timeKillEvent)(UINT uTimerID); + static MCIERROR (*func_mciSendCommandW)(MCIDEVICEID mciId,UINT uMsg,DWORD_PTR dwParam1,DWORD_PTR dwParam2); + + static void initWinmmDll() + { + winmmDll = NULL; + func_timeBeginPeriod = NULL; + func_timeEndPeriod = NULL; + func_timeSetEvent = NULL; + func_timeKillEvent = NULL; + func_mciSendCommandW = NULL; + } + + static bool loadWinmmDll() + { + // winmm.dll + if (winmmDll == NULL) { + winmmDll = LoadLibraryA("winmm.dll"); + if (winmmDll == NULL) { + LOG("ege error: Failed to load winmm.dll."); + return false; + } + } + + // timeBeginPeriod + if (func_timeBeginPeriod == NULL) { + typedef MMRESULT (*timeBeginPeriod_FuncType)(UINT uPeriod); + func_timeBeginPeriod = (timeBeginPeriod_FuncType)GetProcAddress(winmmDll, "timeBeginPeriod"); + LOG_IF(func_timeBeginPeriod == NULL, "ege error: The 'timeBeginPeriod' function cannot be found from the winmm.dll."); + } + + // timeEndPeriod + if (func_timeEndPeriod == NULL) { + typedef MMRESULT (*timeEndPeriod_FuncType)(UINT uPeriod); + func_timeEndPeriod = (timeEndPeriod_FuncType)GetProcAddress(winmmDll, "timeEndPeriod"); + LOG_IF(func_timeEndPeriod == NULL, "ege error: The 'timeEndPeriod' function cannot be found from the winmm.dll."); + } + + + // timeSetEvent + if (func_timeSetEvent == NULL) { + typedef MMRESULT (*timeSetEvent_FuncType)(UINT uDelay,UINT uResolution,LPTIMECALLBACK fptc,DWORD_PTR dwUser,UINT fuEvent); + func_timeSetEvent = (timeSetEvent_FuncType)GetProcAddress(winmmDll, "timeSetEvent"); + LOG_IF(func_timeSetEvent == NULL, "ege error: The 'timeSetEvent' function cannot be found from the winmm.dll."); + } + + // timeKillEvent + if (func_timeKillEvent == NULL) { + typedef MMRESULT (*timeKillEvent_FuncType)(UINT uTimerID); + func_timeKillEvent = (timeKillEvent_FuncType)GetProcAddress(winmmDll, "timeKillEvent"); + LOG_IF(func_timeKillEvent == NULL, "ege error: The 'timeKillEvent' function cannot be found from the winmm.dll."); + } + + + // mciSendCommandW + if (func_mciSendCommandW == NULL) { + typedef MCIERROR (*mciSendCommandW_FuncType)(MCIDEVICEID mciId,UINT uMsg,DWORD_PTR dwParam1,DWORD_PTR dwParam2); + func_mciSendCommandW = (mciSendCommandW_FuncType)GetProcAddress(winmmDll, "mciSendCommandW"); + LOG_IF(func_mciSendCommandW == NULL, "ege error: The 'mciSendCommandW' function cannot be found from the winmm.dll."); + } + + return func_timeBeginPeriod && func_timeEndPeriod && func_timeSetEvent && func_timeKillEvent && func_mciSendCommandW; + } + + MMRESULT timeBeginPeriod(UINT uPeriod) + { + if (func_timeBeginPeriod) { + return func_timeBeginPeriod(uPeriod); + } + return NULL; + } + + MMRESULT timeEndPeriod(UINT uPeriod) + { + if (func_timeEndPeriod) { + func_timeEndPeriod(uPeriod); + } + return NULL; + } + + MMRESULT timeSetEvent(UINT uDelay,UINT uResolution,LPTIMECALLBACK fptc,DWORD_PTR dwUser,UINT fuEvent) + { + if (func_timeSetEvent) { + return func_timeSetEvent(uDelay, uResolution, fptc, dwUser, fuEvent); + } + + return NULL; + } + + MMRESULT timeKillEvent(UINT uTimerID) + { + if (func_timeKillEvent) { + return func_timeKillEvent(uTimerID); + } + + return NULL; + } + + MCIERROR mciSendCommandW(MCIDEVICEID mciId,UINT uMsg,DWORD_PTR dwParam1,DWORD_PTR dwParam2) + { + if (func_mciSendCommandW) { + return func_mciSendCommandW(mciId, uMsg, dwParam1, dwParam2); + } + + return NULL; + } + + // ---------------------------------------------------------------------------- + // 加载 dll 以及需要的符号 + void loadDllsIfNot() + { + static bool loadingIsFinished = false; + static bool firstCall = true; // 初次调用标记, 因不同编译单元初始化顺序未保证, 防止静态变量未初始化 + + if (firstCall) { + initImm32Dll(); + initMsimg32Dll(); + initWinmmDll(); + firstCall = false; + } + + if (!loadingIsFinished) { + bool isSuccessful = true; + + isSuccessful = loadImm32Dll() && isSuccessful; + isSuccessful = loadMsimg32Dll() && isSuccessful; + isSuccessful = loadWinmmDll() && isSuccessful; + + loadingIsFinished = isSuccessful; + } + } + + // 释放所有加载的 dll (imm32.dll, msimg32.dll, winmm.dll) + void freeDlls() + { + if (imm32Dll != NULL) { + FreeLibrary(imm32Dll); + } + + if (msimg32Dll != NULL) { + FreeLibrary(msimg32Dll); + } + + if (winmmDll != NULL) { + FreeLibrary(winmmDll); + } + } + + // 临时从 dll 中加载 CreateStreamOnHGlobal 函数并调用 + HRESULT CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm) + { + HMODULE Ole32Dll = LoadLibraryA("Ole32.dll"); + if (Ole32Dll == NULL) { + LOG("ege error: Failed to load Ole32.dll."); + return S_FALSE; + } + + typedef HRESULT (*CreateStreamOnHGlobalFuncType) (HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm); + CreateStreamOnHGlobalFuncType CreateStreamOnHGlobalFunc = (CreateStreamOnHGlobalFuncType)GetProcAddress(Ole32Dll, "CreateStreamOnHGlobal"); + + HRESULT result; + if (CreateStreamOnHGlobalFunc == NULL) { + LOG("ege error: The 'CreateStreamOnHGlobal' function cannot be found from the Ole32.dll."); + result = S_FALSE; + } else { + result = CreateStreamOnHGlobalFunc(hGlobal, fDeleteOnRelease, ppstm); + } + + FreeLibrary(Ole32Dll); + return result; + } + +} + diff --git a/src/ege_dllimport.h b/src/ege_dllimport.h new file mode 100644 index 00000000..68147c51 --- /dev/null +++ b/src/ege_dllimport.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include + +namespace dll +{ + // 如果没加载 dll 则进行加载 + void loadDllsIfNot(); + + // 释放所有加载的 dll + void freeDlls(); + + // 临时从 dll 中加载 CreateStreamOnHGlobal 函数并调用 + HRESULT CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm); + + // --------------------- imm32.dll ----------------------- + HIMC ImmGetContext(HWND hwnd); + BOOL ImmSetCompositionWindow(HIMC,LPCOMPOSITIONFORM); + + // --------------------- msimg32.dll --------------------- + BOOL AlphaBlend(HDC hdcDest,int xoriginDest,int yoriginDest,int wDest,int hDest,HDC hdcSrc,int xoriginSrc,int yoriginSrc,int wSrc,int hSrc,BLENDFUNCTION ftn); + BOOL GradientFill(HDC hdc, PTRIVERTEX pVertex, ULONG nVertex, PVOID pMesh, ULONG nMesh, ULONG ulMode); + + // --------------------- winmm.dll ----------------------- + MMRESULT WINAPI timeBeginPeriod(UINT uPeriod); + MMRESULT WINAPI timeEndPeriod(UINT uPeriod); + MMRESULT WINAPI timeSetEvent(UINT uDelay,UINT uResolution,LPTIMECALLBACK fptc,DWORD_PTR dwUser,UINT fuEvent); + MMRESULT WINAPI timeKillEvent(UINT uTimerID); + MCIERROR WINAPI mciSendCommandW(MCIDEVICEID mciId,UINT uMsg,DWORD_PTR dwParam1,DWORD_PTR dwParam2); +} diff --git a/src/ege_graph.h b/src/ege_graph.h index 760f1139..3077363e 100644 --- a/src/ege_graph.h +++ b/src/ege_graph.h @@ -8,11 +8,6 @@ #define GRADIENT_FILL_RECT_V 0x00000001 #define GRADIENT_FILL_TRIANGLE 0x00000002 #define GRADIENT_FILL_OP_FLAG 0x000000ff - -extern "C" -{ -WINGDIAPI BOOL WINAPI GradientFill(HDC hdc, PTRIVERTEX pVertex, ULONG nVertex, PVOID pMesh, ULONG nMesh, ULONG ulMode); -} #endif namespace ege diff --git a/src/egegapi.cpp b/src/egegapi.cpp index 8ea3df2b..8833e2bc 100644 --- a/src/egegapi.cpp +++ b/src/egegapi.cpp @@ -922,7 +922,7 @@ void fillpoly_gradient(int numpoints, const ege_colpoint* polypoints, PIMAGE pim tri[j].Vertex2 = j + 1; tri[j].Vertex3 = j + 2; } - ::GradientFill(img->getdc(), vert, numpoints, tri, numpoints - 2, GRADIENT_FILL_TRIANGLE); + dll::GradientFill(img->getdc(), vert, numpoints, tri, numpoints - 2, GRADIENT_FILL_TRIANGLE); free(tri); } free(vert); diff --git a/src/graphics.cpp b/src/graphics.cpp index 378e2e7c..490bb5af 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -345,6 +345,7 @@ static void on_paint(struct _graph_setting* pg, HWND hwnd) static void on_destroy(struct _graph_setting* pg) { pg->exit_window = 1; + dll::freeDlls(); PostQuitMessage(0); if (pg->close_manually && pg->use_force_exit) { exit(0); @@ -374,11 +375,11 @@ static void on_setcursor(struct _graph_setting* pg, HWND hwnd) static void on_ime_control(struct _graph_setting* pg, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { if (wparam == IMC_SETSTATUSWINDOWPOS) { - HIMC hImc = ImmGetContext(hwnd); + HIMC hImc = dll::ImmGetContext(hwnd); COMPOSITIONFORM cpf = {0}; cpf.dwStyle = CFS_POINT; cpf.ptCurrentPos = *(LPPOINT)lparam; - ImmSetCompositionWindow(hImc, &cpf); + dll::ImmSetCompositionWindow(hImc, &cpf); } } @@ -799,6 +800,8 @@ void initgraph(int* gdriver, int* gmode, const char* path) pg->exit_flag = 0; pg->exit_window = 0; + dll::loadDllsIfNot(); + // 已创建则转为改变窗口大小 if (pg->has_init) { int width = (short)(*gmode & 0xFFFF); diff --git a/src/image.cpp b/src/image.cpp index e482727b..525e5247 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -17,6 +17,7 @@ #include "ege_head.h" #include "ege_common.h" +#include "ege_dllimport.h" // #ifdef _ITERATOR_DEBUG_LEVEL // #undef _ITERATOR_DEBUG_LEVEL @@ -24,8 +25,6 @@ #include -#include "ocidl.h" -#include "olectl.h" #include @@ -64,6 +63,7 @@ void IMAGE::construct(int width, int height) refDC = ::GetDC(graph_setting.hwnd); } + dll::loadDllsIfNot(); gdipluinit(); reset(); initimage(refDC, width, height); @@ -387,23 +387,6 @@ int IMAGE::getimage(LPCSTR filename, int zoomWidth, int zoomHeight) return getimage(filename_w.c_str(), zoomWidth, zoomHeight); } -void getimage_from_IPicture(PIMAGE self, IPicture* pPicture) -{ - long lWidth, lHeight; - - pPicture->get_Width(&lWidth); - pPicture->get_Height(&lHeight); - - // convert Himetric units to pixels - ::HDC ScreenDC = ::GetDC(NULL); - long lWidthPixels = ::MulDiv(lWidth, ::GetDeviceCaps(ScreenDC, LOGPIXELSX), 2540); - long lHeightPixels = ::MulDiv(lHeight, ::GetDeviceCaps(ScreenDC, LOGPIXELSY), 2540); - ::ReleaseDC(NULL, ScreenDC); - - self->resize_f(lWidthPixels, lHeightPixels); - pPicture->Render(getHDC(self), 0, 0, lWidthPixels, lHeightPixels, 0, lHeight, lWidth, -lHeight, 0); -} - int getimage_from_bitmap(PIMAGE pimg, Gdiplus::Bitmap& bitmap) { Gdiplus::PixelFormat srcPixelFormat = bitmap.GetPixelFormat(); @@ -727,7 +710,7 @@ inline int getimage_from_resource(PIMAGE self, HRSRC hrsrc) } memcpy(pvData, pvRes, dwSize); GlobalUnlock(hGlobal); - if (S_OK != CreateStreamOnHGlobal(hGlobal, TRUE, &pStm)) { + if (S_OK != dll::CreateStreamOnHGlobal(hGlobal, TRUE, &pStm)) { return grNullPointer; } @@ -784,7 +767,7 @@ int IMAGE::getimage(void* pMem, long size) } memcpy(pvData, pMem, dwSize); GlobalUnlock(hGlobal); - if (S_OK != CreateStreamOnHGlobal(hGlobal, TRUE, &pStm)) { + if (S_OK != dll::CreateStreamOnHGlobal(hGlobal, TRUE, &pStm)) { return grNullPointer; } @@ -1080,7 +1063,7 @@ int IMAGE::putimage_withalpha(PIMAGE imgdest, // handle to dest bf.SourceConstantAlpha = 0xff; bf.AlphaFormat = AC_SRC_ALPHA; // draw - AlphaBlend(img->m_hDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, alphaSrc->m_hDC, 0, 0, nWidthSrc, + dll::AlphaBlend(img->m_hDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, alphaSrc->m_hDC, 0, 0, nWidthSrc, nHeightSrc, bf); delimage(alphaSrc); } diff --git a/src/music.cpp b/src/music.cpp index 36fcd1fd..3566c606 100644 --- a/src/music.cpp +++ b/src/music.cpp @@ -8,7 +8,6 @@ MUSIC类的定义 #include "ege_head.h" #include "ege_common.h" -#include "mmsystem.h" #ifndef MUSIC_ASSERT_TRUE #ifdef _DEBUG @@ -78,10 +77,10 @@ DWORD MUSIC::OpenFile(LPCWSTR _szStr) Close(); } - mciERR = mciSendCommandW(0, MCI_OPEN, MCI_OPEN_SHAREABLE | MCI_NOTIFY | MCI_OPEN_ELEMENT, (DWORD_PTR)&mci_p); + mciERR = dll::mciSendCommandW(0, MCI_OPEN, MCI_OPEN_SHAREABLE | MCI_NOTIFY | MCI_OPEN_ELEMENT, (DWORD_PTR)&mci_p); if (mciERR != ERROR_SUCCESS) { - mciERR = mciSendCommandW(0, MCI_OPEN, MCI_NOTIFY | MCI_OPEN_ELEMENT, (DWORD_PTR)&mci_p); + mciERR = dll::mciSendCommandW(0, MCI_OPEN, MCI_NOTIFY | MCI_OPEN_ELEMENT, (DWORD_PTR)&mci_p); } if (mciERR == ERROR_SUCCESS) { @@ -92,7 +91,7 @@ DWORD MUSIC::OpenFile(LPCWSTR _szStr) MCI_SET_PARMS mci_p = {0}; mci_p.dwTimeFormat = MCI_FORMAT_MILLISECONDS; // DWORD dw = - mciSendCommandW(m_DID, MCI_SET, MCI_NOTIFY | MCI_SET_TIME_FORMAT, (DWORD_PTR)&mci_p); + dll::mciSendCommandW(m_DID, MCI_SET, MCI_NOTIFY | MCI_SET_TIME_FORMAT, (DWORD_PTR)&mci_p); } } @@ -120,7 +119,7 @@ DWORD MUSIC::Play(DWORD dwFrom, DWORD dwTo) dwFlag |= MCI_TO; } - mciERR = mciSendCommandW(m_DID, MCI_PLAY, dwFlag, (DWORD_PTR)&mci_p); + mciERR = dll::mciSendCommandW(m_DID, MCI_PLAY, dwFlag, (DWORD_PTR)&mci_p); Sleep(1); @@ -136,7 +135,7 @@ DWORD MUSIC::Pause() mci_p.dwCallback = (DWORD_PTR)m_dwCallBack; - mciERR = mciSendCommandW(m_DID, MCI_PAUSE, MCI_NOTIFY, (DWORD_PTR)&mci_p); + mciERR = dll::mciSendCommandW(m_DID, MCI_PAUSE, MCI_NOTIFY, (DWORD_PTR)&mci_p); return mciERR; } @@ -150,7 +149,7 @@ DWORD MUSIC::Stop() mci_p.dwCallback = (DWORD_PTR)m_dwCallBack; - mciERR = mciSendCommandW(m_DID, MCI_STOP, MCI_NOTIFY, (DWORD_PTR)&mci_p); + mciERR = dll::mciSendCommandW(m_DID, MCI_STOP, MCI_NOTIFY, (DWORD_PTR)&mci_p); return mciERR; } @@ -163,7 +162,7 @@ DWORD MUSIC::SetVolume(float value) mci_p.dwItem = MCI_DGV_SETAUDIO_VOLUME; mci_p.dwValue = (DWORD)(value * 1000); // 此处就是音量大小 (0--1000) - mciERR = mciSendCommandW(m_DID, MCI_SETAUDIO, MCI_DGV_SETAUDIO_VALUE | MCI_DGV_SETAUDIO_ITEM, (DWORD_PTR)&mci_p); + mciERR = dll::mciSendCommandW(m_DID, MCI_SETAUDIO, MCI_DGV_SETAUDIO_VALUE | MCI_DGV_SETAUDIO_ITEM, (DWORD_PTR)&mci_p); return mciERR; } @@ -178,7 +177,7 @@ DWORD MUSIC::Seek(DWORD dwTo) mci_p.dwCallback = (DWORD_PTR)m_dwCallBack; mci_p.dwTo = dwTo; - mciERR = mciSendCommandW(m_DID, MCI_SEEK, MCI_NOTIFY, (DWORD_PTR)&mci_p); + mciERR = dll::mciSendCommandW(m_DID, MCI_SEEK, MCI_NOTIFY, (DWORD_PTR)&mci_p); return mciERR; } @@ -192,7 +191,7 @@ DWORD MUSIC::Close() mci_p.dwCallback = (DWORD_PTR)m_dwCallBack; - mciERR = mciSendCommandW(m_DID, MCI_CLOSE, MCI_NOTIFY, (DWORD_PTR)&mci_p); + mciERR = dll::mciSendCommandW(m_DID, MCI_CLOSE, MCI_NOTIFY, (DWORD_PTR)&mci_p); m_DID = MUSIC_ERROR; return mciERR; @@ -210,7 +209,7 @@ DWORD MUSIC::GetPosition() mci_p.dwCallback = (DWORD_PTR)m_dwCallBack; mci_p.dwItem = MCI_STATUS_POSITION; - mciSendCommandW(m_DID, MCI_STATUS, MCI_NOTIFY | MCI_STATUS_ITEM, (DWORD_PTR)&mci_p); + dll::mciSendCommandW(m_DID, MCI_STATUS, MCI_NOTIFY | MCI_STATUS_ITEM, (DWORD_PTR)&mci_p); return (DWORD)mci_p.dwReturn; } @@ -224,7 +223,7 @@ DWORD MUSIC::GetLength() mci_p.dwCallback = (DWORD_PTR)m_dwCallBack; mci_p.dwItem = MCI_STATUS_LENGTH; - mciSendCommandW(m_DID, MCI_STATUS, MCI_NOTIFY | MCI_STATUS_ITEM, (DWORD_PTR)&mci_p); + dll::mciSendCommandW(m_DID, MCI_STATUS, MCI_NOTIFY | MCI_STATUS_ITEM, (DWORD_PTR)&mci_p); return (DWORD)mci_p.dwReturn; } @@ -237,7 +236,7 @@ DWORD MUSIC::GetPlayStatus() mci_p.dwCallback = (DWORD_PTR)m_dwCallBack; mci_p.dwItem = MCI_STATUS_MODE; - mciSendCommandW(m_DID, MCI_STATUS, MCI_NOTIFY | MCI_STATUS_ITEM, (DWORD_PTR)&mci_p); + dll::mciSendCommandW(m_DID, MCI_STATUS, MCI_NOTIFY | MCI_STATUS_ITEM, (DWORD_PTR)&mci_p); return (DWORD)mci_p.dwReturn; } diff --git a/src/time.cpp b/src/time.cpp index 46d7a607..078c742b 100644 --- a/src/time.cpp +++ b/src/time.cpp @@ -8,9 +8,9 @@ namespace ege void api_sleep(long dwMilliseconds) { if (dwMilliseconds >= 0) { - ::timeBeginPeriod(1); + dll::timeBeginPeriod(1); ::Sleep(dwMilliseconds); - ::timeEndPeriod(1); + dll::timeEndPeriod(1); } } @@ -27,9 +27,9 @@ void ege_sleep(long ms) static MMRESULT resTimer = 0; ::ResetEvent(hTimer); if (resTimer) { - ::timeKillEvent(resTimer); + dll::timeKillEvent(resTimer); } - resTimer = ::timeSetEvent(ms, 1, (LPTIMECALLBACK)hTimer, 0, TIME_ONESHOT | TIME_CALLBACK_EVENT_SET); + resTimer = dll::timeSetEvent(ms, 1, (LPTIMECALLBACK)hTimer, 0, TIME_ONESHOT | TIME_CALLBACK_EVENT_SET); if (resTimer) { ::WaitForSingleObject(hTimer, INFINITE); } else { @@ -40,7 +40,7 @@ void ege_sleep(long ms) static HANDLE hTimer = ::CreateWaitableTimer(NULL, TRUE, NULL); LARGE_INTEGER liDueTime; - ::timeBeginPeriod(1); + dll::timeBeginPeriod(1); liDueTime.QuadPart = ms * (LONGLONG)-10000; if (hTimer) { @@ -51,7 +51,7 @@ void ege_sleep(long ms) } else { ::Sleep(ms); } - ::timeEndPeriod(1); + dll::timeEndPeriod(1); } } @@ -233,9 +233,9 @@ double get_highfeq_time_ls(struct _graph_setting* pg) QueryPerformanceCounter(&pg->get_highfeq_time_start); QueryPerformanceFrequency(&llFeq); } else if (0) { - ::timeBeginPeriod(1); + dll::timeBeginPeriod(1); pg->get_highfeq_time_start.QuadPart = ::timeGetTime(); - ::timeEndPeriod(1); + dll::timeEndPeriod(1); llFeq.QuadPart = 1000; } else if (1) { pg->get_highfeq_time_start.QuadPart = ::GetTickCount(); @@ -249,9 +249,9 @@ double get_highfeq_time_ls(struct _graph_setting* pg) if (1) { QueryPerformanceCounter(&llNow); } else if (0) { - ::timeBeginPeriod(1); + dll::timeBeginPeriod(1); llNow.QuadPart = ::timeGetTime(); - ::timeEndPeriod(1); + dll::timeEndPeriod(1); } else if (1) { llNow.QuadPart = ::GetTickCount(); } else if (0) {