Winamp can't be closed with my plugin written in C++/WinApi -
i have written winamp plugin winapi.
when i'm closing winamp, gui (both winamp's , plugin's windows) disappearing... can still see winamp.exe in windows taskmanager.
after deleting gen_mood.dll (my plug-in file) winamp's plug-ins directory, ok - can close winamp correctly.
here minimal code. can tell me wrong? i'm using visual studio 2013 , winamp 5.666.
gen_mood.cpp:
#include "stdafx.h" #include <windows.h> #include "gen_mood.h" // these callback functions/events called winamp int init(void); void config(void); void quit(void); void makesetlist(); using namespace std; // structure contains plugin information, version, name... // gpphdr_ver version of winampgeneralpurposeplugin (gpp) structure winampgeneralpurposeplugin plugin = { gpphdr_ver, // version of plugin, defined in "gen_mood.h" plugin_name, // name/title of plugin, defined in "gen_mood.h" init, // function name executed on init event config, // function name executed on config event quit, // function name executed on quit event 0, // handle winamp main window, loaded winamp when dll loaded 0 // hinstance dll, loaded winamp when dll 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() {} // export function called winamp returns plugin info. // wrap code in 'extern "c"' ensure export isn't mangled if used in 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 like) #define plugin_name "mood" // main structure plugin information, version, name... typedef struct { int version; // version of plugin structure char *description; // name/title of plugin int(*init)(); // function executed on init event void(*config)(); // function executed on config event void(*quit)(); // function executed on quit event hwnd hwndparent; // hwnd of winamp client main window (stored winamp when dll loaded) hinstance hdllinstance; // hinstance of plugin dll. (stored winamp when dll loaded) } winampgeneralpurposeplugin; #endif //gen_mood_h
i have found solution. there problem
while (getmessage(&komunikat, null, 0, 0)) { translatemessage(&komunikat); dispatchmessage(&komunikat); }
winamp's main window running message pump pointless write own. have deleted lines , works fine.
Comments
Post a Comment