mIRC Homepage
Posted By: The_JD Pulling my hair out over DLL - 03/10/07 03:47 AM
New to C++ 2005 Express.
Having some issues creating a mIRC DLL in it.

I would really like it if someone could create a "Hello world" dll in:

Visual C++ 2005 Express Edition.

Just a simple way to return 'Hello World'

Perhaps a DLLinfo section containing the Authors info.
Thanks,
JD.

Looking around, I have not seen any information about VC++2k5E mirc dll's.
Posted By: The_JD Re: Pulling my hair out over DLL - 03/10/07 03:52 AM
and please .zip the full project... not just the main file... I need to be able to compile it smile

Thanks again,
JD.
Posted By: argv0 Re: Pulling my hair out over DLL - 03/10/07 03:55 AM
My ruby4mirc DLL (located at http://kthx.net/ruby4mirc) compiles in VS.NET 2005. Source code is available there that you can use as a reference.

Keep in mind that the Express version of VS is missing many SDK's and toolkits needed to properly compile a lot of applications, though it should be able to compile a minimal DLL just fine

You may want to elaborate on your problem though-- are you having trouble compiling, or running the DLL in mIRC? You have to make sure your symbols are propertly exported, if you were able to compile.

Generally, a minimal dll source file hello.c looks like:

Code:
#include <windows.h>

int __declspec(dllexport) __stdcall helloWorld(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)
{
  strcpy(data, "Hello world");
  return 3;
}


With a hello.def file (for the exports)

Code:
LIBRARY hello
EXPORTS
helloWorld


And would be used in mirc as:

Code:
//echo -a $dll(hello.dll,helloWorld,$null)


Posted By: The_JD Re: Pulling my hair out over DLL - 03/10/07 04:15 AM
Wow, Thanks for the quick reply...


Ill check it out now, and let you know how I go ASAP.

The truth: The problem im having is i'm a C++ noob.
Lies: Something went wrong.

Lol, I've only create com dll's in VB6 for mIRC.

I'm working on it.
Posted By: The_JD Re: Pulling my hair out over DLL - 03/10/07 06:34 AM
If i include the include for windows.h it tells me it is not found.
otherwise, i get this:

c:\documents and settings\jd\desktop\mircdll\hello.c(3) : error C2146: syntax error : missing ')' before identifier 'mWnd'
c:\documents and settings\jd\desktop\mircdll\hello.c(3) : error C2061: syntax error : identifier 'mWnd'
c:\documents and settings\jd\desktop\mircdll\hello.c(3) : error C2059: syntax error : ';'
c:\documents and settings\jd\desktop\mircdll\hello.c(3) : error C2059: syntax error : ','
c:\documents and settings\jd\desktop\mircdll\hello.c(3) : error C2059: syntax error : ')'
Posted By: argv0 Re: Pulling my hair out over DLL - 03/10/07 09:24 PM
If you're missing windows.h it's likely because VS.net Express 2005 doesn't include the windows SDK's required to compiled windows applications, which is totally likely, because that's something you'd expect microsoft to do... give you free software that can do absolutely nothing with.

There are free alternatives to compiling dlls, like MingW and cygwin's gcc compiler. Try those.
Posted By: hixxy Re: Pulling my hair out over DLL - 03/10/07 09:37 PM
You have to install the platform SDK separately. You can get it from the Microsoft website.
Posted By: argv0 Re: Pulling my hair out over DLL - 03/10/07 10:21 PM
Note that in the case of this specific dll where you make no calls to the windows api, you don't actually need to #include <windows.h> if you didn't want to, you'd just have to replace the HWND with void * and BOOL with .. int?


But I don't recommend that at all, unless you just want to see if you're going to run into other problems beyond the windows.h thing.
Posted By: The_JD Re: Pulling my hair out over DLL - 04/10/07 02:10 AM
Just testing off that

---
c:\documents and settings\jd\desktop\mircdll\hello.c(5) : warning C4013: 'strcpy' undefined; assuming extern returning int
---

Im guessing that requires the platform SDK as well?

Finally the DLL will actually compile, so I guess its a start.
All I want to do right now is return a string.

I'm not sure which platform SDK to download... I found the Win3kServerR2 PSDK but not sure if it's what i'm on as im on XP?

This help is really appreciated guys
Posted By: Sais Re: Pulling my hair out over DLL - 04/10/07 02:51 PM
Looks like the "Microsoft ® Windows Server® 2003 R2 Platform SDK" is supported on XP, too (read the requirements!)

strcpy would be from the #include <string.h> and requires the libc.lib library (You should be able to find that out by highlighting "strcpy" in the IDE and pressing F1...although I find MS's helpfile to be more difficult to understand than necessary.) Not sure whether that is in the PSDK or not - I'm sure I've used it without any problems, but I didn't have too many difficulties installing the PSDK.

There are some instructions on installing the PSDK here ... (Isn't this getting a little OT? wink
Posted By: The_JD Re: Pulling my hair out over DLL - 04/10/07 04:23 PM
Ok, I installed the SDK, ran some batch files etc etc...
Didnt know I had to update stuff manually

But http://www.nuclex.org/articles/setting-up-visual-cxx-express was very helpful... All seems well right now, Ill let you know how this works.

Now I have access to windows.h, things should work better.
Posted By: The_JD Re: Pulling my hair out over DLL - 04/10/07 04:57 PM
Code:
------ Build started: Project: hello, Configuration: Debug Win32 ------
Compiling...
hello.c
Linking...
Embedding manifest...
Build log was saved at "file://c:\Documents and Settings\JD\Desktop\MircDLL\Debug\BuildLog.htm"
hello - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========


Looks good, Right?
But now mIRC says: * $dll: no such routine 'helloWorld'
Posted By: argv0 Re: Pulling my hair out over DLL - 05/10/07 02:01 AM
Do you have the .def file in the project?
Posted By: The_JD Re: Pulling my hair out over DLL - 05/10/07 02:26 AM
Yep
Posted By: The_JD Re: Pulling my hair out over DLL - 05/10/07 06:21 AM
Thanks Guys - Finally have it all working...

Bigger thanks to Argv[0] (Hope i spelt that right) for help here and on #mIRC in EFnet.
© mIRC Discussion Forums