2014-09-10 4 views
-1

WinApi로 Winamp 플러그인을 작성했습니다.Winamp를 C++/WinApi로 작성된 플러그인으로 닫을 수 없습니다.

Winamp를 닫을 때 GUI (Winamp 및 내 플러그인 창 모두)가 사라지고 있지만 Windows TaskManager에서 Winamp.exe를 볼 수 있습니다.

Winamp의 플러그인 디렉토리에서 gen_mood.dll (내 플러그 인 파일)을 삭제하면 모든 것이 정상입니다. Winamp를 올바르게 닫을 수 있습니다.

여기 내 코드가 있습니다. 누군가가 잘못되었다고 말할 수 있습니까? Visual Studio 2013 및 Winamp 5.666을 사용하고 있습니다.

gen_mood.cpp :

#include "stdafx.h" 
#include <windows.h> 
#include "gen_mood.h" 

// these are callback functions/events which will be called by Winamp 
int init(void); void config(void); void quit(void); void makeSetlist(); 
using namespace std; 


// this structure contains plugin information, version, name... // GPPHDR_VER is the version of the winampGeneralPurposePlugin (GPP) structure 
winampGeneralPurposePlugin plugin = { 

GPPHDR_VER, // version of the plugin, defined in "gen_mood.h" 
PLUGIN_NAME, // name/title of the plugin, defined in "gen_mood.h" 
init,  // function name which will be executed on init event 
config,  // function name which will be executed on config event 
quit,  // function name which will be executed on quit event 
0,   // handle to Winamp main window, loaded by winamp when this dll is loaded 
0   // hinstance to this dll, loaded by winamp when this dll is loaded 

}; 

// event functions follow 
MSG Komunikat; 
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 
HWND hwnd; 
int init() { 

    HFONT hNormalFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); 
    LPCWSTR ClassName = L"Class name"; 
    WNDCLASSEX wc; 

    wc.cbSize = sizeof(WNDCLASSEX); 
    wc.style = CS_VREDRAW; 
    wc.lpfnWndProc = WndProc; 
    wc.cbClsExtra = 0; 
    wc.cbWndExtra = 0; 
    wc.hInstance = plugin.hDllInstance; 
    wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); 
    wc.hCursor = LoadCursor(NULL, IDC_ARROW); 
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 
    wc.lpszMenuName = NULL; 
    wc.lpszClassName = ClassName; 
    wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); 

    RegisterClassEx(&wc); 
    hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, ClassName, L"Name", WS_OVERLAPPED, 100, 100, 100, 100, plugin.hwndParent, NULL, plugin.hDllInstance, NULL); 
    ShowWindow(hwnd, SW_SHOW); 
    UpdateWindow(hwnd); 

    while (GetMessage(&Komunikat, NULL, 0, 0)) 
    { 
     TranslateMessage(&Komunikat); 
     DispatchMessage(&Komunikat); 
    } 

    return 0; 
} 

void config() {} 
void quit() {} 

// This is an export function called by winamp which returns this plugin info. // We wrap the code in 'extern "C"' to ensure the export isn't mangled if used in a CPP file. 
extern "C" __declspec(dllexport) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin() { 

return &plugin; 

} 
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 
{ 
    switch (msg) 
    { 
    case WM_CLOSE: 
     DestroyWindow(hwnd); 
     break; 
    case WM_DESTROY: 
     PostQuitMessage(0); 
     break; 
    default: 
     return DefWindowProc(hwnd, msg, wParam, lParam); 
    } 
    return 0; 
} 

gen_mood.h : 나는 해결책을 발견

#ifndef gen_mood_h 
#define gen_mood_h 
#include <windows.h> 

// plugin version (don't touch this) 
#define GPPHDR_VER 0x10 

// plugin name/title (change this to something you like) 
#define PLUGIN_NAME "Mood" 


// main structure with plugin information, version, name... 
typedef struct { 

    int version;     // version of the plugin structure 
    char *description;    // name/title of the plugin 
    int(*init)();     // function which will be executed on init event 
    void(*config)();    // function which will be executed on config event 
    void(*quit)();    // function which will be executed on quit event 
    HWND hwndParent;    // hwnd of the Winamp client main window (stored by Winamp when dll is loaded) 
    HINSTANCE hDllInstance;  // hinstance of this plugin DLL. (stored by Winamp when dll is loaded) 

} winampGeneralPurposePlugin; 


#endif //gen_mood_h 
+0

디버거를 연결하고 닫을 때 플러그인 코드에서 어떤 일이 발생하는지 확인할 수 없습니까? – stijn

답변

0

.

while (GetMessage(&Komunikat, NULL, 0, 0)) 
{ 
    TranslateMessage(&Komunikat); 
    DispatchMessage(&Komunikat); 
} 

Winamp의 메인 윈도우가 메시지 펌프를 실행하고있어서 내 자신을 쓸모가 없었습니다. 이 줄을 지우고 모든 것이 잘 작동합니다.