I changed it to a *char. Anyhow, I give up. Again. Heres my code:
Requires the winamp headers from yPlugin.
// Credit -
// Joe[e2]: Author
// iago[x86]: Original XMMS Plugin
#include <unistd.h>
#include <ctype.h>
#include <string.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "WinampFunctions.h"
#include "internal.h"
#include "gtkgaim.h"
#include "debug.h"
#include "signals.h"
#include "util.h"
#include "version.h"
#include "cmds.h"
#include "conversation.h"
#include "gtkplugin.h"
#include "gtkutils.h"
#include <windows.h>
//Plugin info - iago[x86]
#define VERSION "0.1.1"
#define ME "Winamp Plugin"
#define MAXLENGTH 1024
#define XMMS_PLUGIN_VERSION "I am using Winamp Plugin v1.0.1 written by Joe with very special thanks to iago and Yoni."
//Handle to the procedures to handle commands - iago[x86]
static GaimCmdId noargcmd;
//write_conversation - iago[x86]
void write_conversation(GaimConversation *conv, const char *message) {
gaim_conversation_write(conv, "", message, GAIM_MESSAGE_NO_LOG, time( NULL ));
}
// WampNoParams - Joe[e2]/iago[x86]
gboolean WampNoParams(GaimConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data) {
write_conversation("Current MP3: " + mp3());
return GAIM_CMD_STATUS_OK;
}
// plugin_load - Joe[e2]/iago[x86]
static gboolean plugin_load(GaimPlugin *plugin) {
noargcmd = gaim_cmd_register("winamp", "", GAIM_CMD_P_DEFAULT, GAIM_CMD_FLAG_IM, NULL, (GaimCmdFunc)WampNoParams, "/Wamp", NULL);
return TRUE;
}
static gboolean plugin_unload(GaimPlugin *plugin) {
gaim_cmd_unregister (noargcmd);
return TRUE;
}
static GaimPluginInfo info = {
GAIM_PLUGIN_MAGIC,
GAIM_MAJOR_VERSION,
GAIM_MINOR_VERSION,
GAIM_PLUGIN_STANDARD, /* type */
NULL, /* ui_requirement */
0, /* flags */
NULL, /* dependencies */
GAIM_PRIORITY_DEFAULT, /* priority */
NULL, /* id */
N_("Winamp Plugin"), /* name */
VERSION, /* version */
N_("Allows use of the /mp3 command."), /* summary */
N_("Allows use of the /mp3 command."), /* description */
"Joe <joetheodd@gmail.com", /* author */
"http://www.x86labs.org", /* homepage */
plugin_load, /* load */
plugin_unload, /* unload */
NULL, /* destroy */
NULL, /* ui_info */
NULL, /* extra_info */
NULL,
NULL
};
// stolen from iago[x86]
static void init_plugin(GaimPlugin *plugin) {
}
GAIM_INIT_PLUGIN(XMMSPlugin, init_plugin, info)
// mp3
/*
char() mp3() {
String title;
HWND HwndWamp;
int len;
HwndWamp = FindWindow("Winamp v1.x", "");
if(HwndWamp = 0) {
return "Winamp not found.";
}else{
len = GetWindowTextLength(HwndWamp) + 1;
GetWindowText(HwndWamp, title, len);
title = title.substr(0, strlen(title) - 1);
title = title.substr(0, strlen(title) - 9);
return title;
}
}
*/
char *mp3(HWND Winamp, DWORD Index) /* Winamp 2.04+, pointer is in local address space */ {
static char SongTitle[1024];
DWORD WinampProcessID;
HANDLE WinampProcess;
char *SongTitleRemote;
char Ret = NULL; // Return value
// Get process ID
GetWindowThreadProcessId(Winamp, &WinampProcessID);
// Open process
if(WinampProcess = OpenProcess(PROCESS_VM_READ, FALSE, WinampProcessID)) {
// Get pointer
if(SongTitleRemote = GetWinampSongTitleRemote(Winamp, Index))
// Try to read it
if(ReadProcessMemory(WinampProcess, SongTitleRemote, SongTitle, sizeof(SongTitle), NULL))
// Success
Ret = SongTitle;
CloseHandle(WinampProcess);
}
return *Ret;
}