C++ Winamp can';我的插件不能用C++/WinApi

C++ Winamp can';我的插件不能用C++/WinApi,c++,winapi,winamp,C++,Winapi,Winamp,我已经用WinApi编写了一个Winamp插件 当我关闭Winamp时,GUI(Winamp和我的插件的窗口)正在消失。。。但我仍然可以在Windows TaskManager中看到Winamp.exe 从Winamp的插件目录中删除gen_mood.dll(我的插件文件)后,一切正常-我可以正确关闭Winamp 这是我的最小代码。有人能告诉我怎么了吗?我正在使用Visual Studio 2013和Winamp 5.666 gen_mood.cpp: #include "stdafx.h" #

我已经用WinApi编写了一个Winamp插件

当我关闭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;
}
#包括“stdafx.h”
#包括
#包括“gen_mood.h”
//这些是Winamp将调用的回调函数/事件
int init(void);void配置(void);作废退出(作废);void makeSetlist();
使用名称空间std;
//此结构包含插件信息、版本、名称…/GPPHDR\u VER是winampGeneralPurposePlugin(GPP)结构的版本
winampGeneralPurposePlugin插件={
GPPHDR\u VER,//插件的版本,在“gen\u mood.h”中定义
PLUGIN\u NAME,//插件的名称/标题,在“gen\u mood.h”中定义
init,//将在init事件上执行的函数名
config,//将在config事件上执行的函数名
quit,//将在quit事件上执行的函数名
0,//Winamp主窗口的句柄,在加载此dll时由Winamp加载
0//h加载此dll时winamp加载此dll的状态
};
//事件函数如下
MSG Komunikat;
LRESULT回调WndProc(HWND HWND、UINT msg、WPARAM WPARAM、LPARAM LPARAM);
HWND-HWND;
int init(){
HFONT hNormalFont=(HFONT)GetStockObject(默认为GUI字体);
LPCWSTR ClassName=L“类名”;
WNDCLASSEX wc;
wc.cbSize=sizeof(WNDCLASSEX);
wc.style=CS_VREDRAW;
wc.lpfnWndProc=WndProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=plugin.hdlinstance;
wc.hIcon=LoadIcon(空,IDI_应用程序);
wc.hCursor=LoadCursor(空,IDC_箭头);
wc.hbrBackground=(HBRUSH)(彩色窗口+1);
wc.lpszMenuName=NULL;
wc.lpszClassName=ClassName;
wc.hIconSm=LoadIcon(空,IDI_应用程序);
注册类别(&wc);
hwnd=CreateWindowEx(WS_EX_CLIENTEDGE,ClassName,L“Name”,WS_重叠,100,100,100,plugin.hwndpresent,NULL,plugin.hdlinstance,NULL);
展示窗口(hwnd、SW_展示);
更新窗口(hwnd);
while(GetMessage(&Komunikat,NULL,0,0))
{
翻译信息(和共济会);
调度信息(和共青团);
}
返回0;
}
void config(){}
void quit(){}
//这是winamp调用的导出函数,返回此插件信息。//我们将代码包装在“extern“C”中,以确保在CPP文件中使用时不会损坏导出。
外部“C”uu declspec(dllexport)winampGeneralPurposePlugin*winampgeteneralpurposeplugin(){
返回&插件;
}
LRESULT回调WndProc(HWND HWND,UINT msg,WPARAM WPARAM,LPARAM LPARAM)
{
开关(msg)
{
案例WM_结束:
窗口(hwnd);
打破
案例WM_销毁:
PostQuitMessage(0);
打破
违约:
返回DefWindowProc(hwnd、msg、wParam、lParam);
}
返回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
\ifndef gen\u mood\u h
#定义gen_mood_h
#包括
//插件版本(不要触摸此)
#定义GPPHDR\u版本0x10
//插件名称/标题(将其更改为您喜欢的内容)
#定义插件名称“Mood”
//包含插件信息、版本、名称的主结构。。。
类型定义结构{
int version;//插件结构的版本
char*description;//插件的名称/标题
int(*init)(;//将在init事件上执行的函数
void(*config)(;//将在配置事件上执行的函数
void(*quit)(;//将在退出事件时执行的函数
HWND hwndParent;//Winamp客户端主窗口的HWND(加载dll时由Winamp存储)
HINSTANCE hDllInstance;//此插件DLL的HINSTANCE。(加载DLL时由Winamp存储)
}温纳普普普斯普洛金;
#endif//gen\u mood\h

我找到了一个解决方案。这是一个问题

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

Winamp的主窗口正在运行一个消息泵,因此编写自己的消息泵是毫无意义的。我已经删除了这几行,现在一切都正常了。

你不能附加调试器并在关闭时检查插件代码中发生了什么吗?