layer Posted February 22, 2005 Posted February 22, 2005 (edited) ive been trying to create a ConsoleDll for a calculator.. but if i just use this (the Template for a Console App in Dev-C++)#include <windows.h> #include <cstdlib> #include <iostream> using namespace std; extern "C" declspec(dllexport) int main(int argc, char *argv[]) { system("PAUSE"); return EXIT_SUCCESS; }i think thats how it goes, just sort of off the top of my head, but you get the point.. that will work if i do a DllCall ("CalcQ.dll", "int", "Main")then i get the console window... but when i use this:expandcollapse popup/* Replace "dll.h" with the name of your header */ #include "dll.h" #include <windows.h> #include <cstdlib> #include <iostream> DllClass::DllClass() { } DllClass::~DllClass () { } BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ , DWORD reason /* Reason this function is being called. */ , LPVOID reserved /* Not used. */ ) { switch (reason) { case DLL_PROCESS_ATTACH: break; case DLL_PROCESS_DETACH: break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; } /* Returns TRUE on success, FALSE on failure */ return TRUE; } using namespace std; extern "C"__declspec(dllexport) int main () { char buffer [100]; int a; int b; cout << "Enter a number: "; cin.getline (buffer,100); a= atof (buffer); cout << "Enter another number: "; cin.getline (buffer,100); b= atoi (buffer); cout << "Sum of both numbers: " << a+b; cout << " \n"; system("pause"); return 0; }then i get no window, when i use DllCall ("CalcQ.dll", "int", "Main")i dont even get the console to pop up for a milisecond, just the tray icon for autoit really fast and then it dissapears.. any ideas why? :"> thanks! EDIT: fixed some coding.. Edited February 22, 2005 by layer FootbaG
layer Posted February 22, 2005 Author Posted February 22, 2005 doh, what ever, is what i mean is calling that Dll will create a Console Window, now will you help me?!?!?! FootbaG
layer Posted February 22, 2005 Author Posted February 22, 2005 (edited) argh... it works fine as an EXE... but i still can't get it to work inside a DllCall! (i know your probably saying why not just stick with the .EXE created and forget about the DllCall, well it's because i want to see if i can have a Console in autoit) i attached the .EXE of the program below, and source.. EDIT: grr, why can't i post a .CPP file.. ill do a zip, hang on there we go, its in a ZIP now.. Edited February 22, 2005 by layer FootbaG
Valik Posted February 22, 2005 Posted February 22, 2005 Its probably pretty easy to create a console window in AutoIt but you're barking up the wrong tree with your code. Go to MSDN and have a look at AllocConsole and it's related functions.
layer Posted February 22, 2005 Author Posted February 22, 2005 (edited) hmmm... i see where ur goingDllCall ("kernel32.dll", "int", "AllocConsole") DllCall ("kernel32.dll", "int", "AttacchConsole", "int", "AutoIt3.exe") While 1 Sleep (100) WEndthanks a bunch Valik! EDIT: for anyone whos interested..AllocConsole: http://msdn.microsoft.com/library/default....llocconsole.aspAttachConsole: http://msdn.microsoft.com/library/default....tachconsole.aspand theres a whole bunch of other Console commands there too, just look around... Edited February 22, 2005 by layer FootbaG
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now