Hey all
i'm stuck in my little project. My plan is to build a application that can interact with a q3-engine game, nothing fancy, i just want to be able to read and send to the game console. magically i managed to actaully create a .exe that does this.. (alltho ive never done c coding before)..
ive used a freeware compiler called dev-c++ (from bloodshed.net) ..anyways..i dont have any references to other compilers.. this just looked easiest.
now, i understand i gotta compile a dll instead of an exe, but i simply doesent know the basics of doing that, i guess you have to declare how you will access the dll..
so i guess the short question is.. how do i compile a DLL from my exisitng code.. in a way so i can call the functions from "outisde"..
now ive tested my exe, and the working code for the .exe is:
#include <windows.h>
#include <iostream.h>
#include <string>
using namespace std;
#pragma warning(disable:4129)
#define PARENTWND "ET Console"
#define CHILDWND "Edit"
#define MAX_BUFFER 16384
#define CR 13
#define LF 10
static HWND hwndParent = NULL;
static HWND hwndEdit = NULL;
static HWND hwndConsole = NULL;
char consolestream[16384];
void SetWindowHandles() {
hwndParent = FindWindow(0, PARENTWND);
hwndEdit = FindWindowEx(hwndParent, NULL, CHILDWND, NULL);
hwndConsole = FindWindowEx(hwndParent, NULL, CHILDWND, NULL);
hwndConsole = FindWindowEx(hwndParent, hwndEdit, CHILDWND, NULL);
}
void SendToET(char *String) {
SendMessage(hwndEdit, WM_SETTEXT, 0, (LPARAM)String);
SendMessage(hwndEdit, WM_CHAR, CR, 0);
}
void GetFromET() {
SendMessage(hwndEdit, WM_GETTEXT, (WPARAM)sizeof(consolestream), (LPARAM)consolestream);
}
int x = 0;
void doSomething() {
x++;
switch(x) {
case 1:
SendMessage(hwndConsole, WM_GETTEXT, (WPARAM)sizeof(consolestream), (LPARAM)consolestream);
if (consolestream[1] > 0) {
SendToET("clearviewlog");
cout << consolestream << endl; // Prints
}
consolestream[1]= 0; // <-- reset the 3rd char
break;
default: {
x = 0;
break;
}
}
}
int main(){
SetWindowHandles();
setname:
Sleep(25); // time in miliseconds between every doSomething
doSomething(); // doSomething
goto setname;
return 0;
}
from a 3rdpart application i would like to be able to call the two functions called "SendToET" and "GetFromET" ..but i'm stuck at the "compile a proper dll"-point..
the function "SendToET" should just send a string from 3rdpartApp.. and "GetFromET" should just return a string to 3rdpartApp.
right now, this code reads the game console every 25 m/sec, deletes the read data from gameconsole, and then shows the read data in the exe commandline-window, this is how i think it should be, but i just need to further more, be able to call the "SendToET" with custom content/string from 3rdpartApp, and then i finally need the output to be send to 3rdpartApp rather than just be printed in the commandline window.
could anyone with the knowledge spare me a helping hand.. please! :)