Jeg har lige prøvet at gøre det, men det virker ikke. Jeg compiler det ved at trykke build i VS C++, jeg har oprettet mit projekt som et Win32 DLL Projekt.
Jeg har skrevet lidt mere til min kode:
#include <windows.h>
#include <string>
#include "WA_IPC.h"
using namespace std;
HWND getWAHandle()
{
return FindWindowA("Winamp v1.x", NULL);
}
__declspec(dllexport) int __stdcall getPlayingStatus(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)
{
string ret = (char*)SendMessage(getWAHandle(), WM_WA_IPC, 0, IPC_ISPLAYING);
strcpy_s(data, sizeof(data), ret.c_str());
return 3;
}
__declspec(dllexport) int __stdcall getTrackLenght(HWND mWnd, HWND aWnd, char *data, char *parms, bool show, bool nopause)
{
string ret = (char*)SendMessage(getWAHandle(), WM_WA_IPC, 0, IPC_GETOUTPUTTIME);
strcpy_s(data, sizeof(data), ret.c_str());
return 3;
}
__declspec(dllexport) int __stdcall getTrackPosition(HWND mWnd, HWND aWnd, char *data, char *parms, bool show, bool nopause)
{
int ret = (int)SendMessage(getWAHandle(), WM_WA_IPC, 0, IPC_GETOUTPUTTIME);
ret = ret / 1000;
char *vRet = (char*)ret;
strcpy_s(data, sizeof(data), vRet);
return 3;
}
__declspec(dllexport) int __stdcall getPlaylistLenght(HWND mWnd, HWND aWnd, char *data, char *parms, bool show, bool nopause)
{
string ret = (char*)SendMessage(getWAHandle(), WM_WA_IPC, 0, IPC_GETLISTLENGHT);
strcpy_s(data, sizeof(data), ret.c_str());
return 3;
}
__declspec(dllexport) int __stdcall getPlaylistIndex(HWND mWnd, HWND aWnd, char *data, char *parms, bool show, bool nopause)
{
string ret = (char*)SendMessage(getWAHandle(), WM_WA_IPC, 0, IPC_GETLISTPOS);
strcpy_s(data, sizeof(data), ret.c_str());
return 3;
}
__declspec(dllexport) int __stdcall getSampleRate(HWND mWnd, HWND aWnd, char *data, char *parms, bool show, bool nopause)
{
string ret = (char*)SendMessage(getWAHandle(), WM_WA_IPC, 0, IPC_GETINFO);
strcpy_s(data, sizeof(data), ret.c_str());
return 3;
}
__declspec(dllexport) int __stdcall getBitRate(HWND mWnd, HWND aWnd, char *data, char *parms, bool show, bool nopause)
{
string ret = (char*)SendMessage(getWAHandle(), WM_WA_IPC, 1, IPC_GETINFO);
strcpy_s(data, sizeof(data), ret.c_str());
return 3;
}
__declspec(dllexport) int __stdcall getShuffleStatus(HWND mWnd, HWND aWnd, char *data, char *parms, bool show, bool nopause)
{
string ret = (char*)SendMessage(getWAHandle(), WM_WA_IPC, 0, IPC_GETSHUFFLE);
strcpy_s(data, sizeof(data), ret.c_str());
return 3;
}
__declspec(dllexport) int __stdcall getTrackTitle(HWND mWnd, HWND aWnd, char *data, char *parms, bool show, bool nopause)
{
size_t strLen;
char pBuffer[256];
GetWindowText(getWAHandle(), (LPWSTR)pBuffer, sizeof(pBuffer));
string s = pBuffer;
strLen = s.length();
s.erase(strLen - 9, strLen);
int playPos = (int)SendMessage(getWAHandle(), WM_WA_IPC, 0, IPC_GETLISTPOS);
s.erase(1, sizeof(playPos) - 2);
strcpy_s(data, sizeof(data), s.c_str());
return 3;
}
min header fil:
#define WM_WA_IPC WM_USER
#define IPC_ISPLAYING 104
#define IPC_GETOUTPUTTIME 105
#define IPC_GETLISTLENGHT 124
#define IPC_GETLISTPOS 125
#define IPC_GETINFO 126
#define IPC_GETSHUFFLE 250
Jeg tester scriptet i mIRC, ved et mIRC script. Jeg er sikker på at der ikke er noget i vejen med dette script da det virker fint med en anden dll fil.