|
-
Nov 17th, 2001, 03:56 AM
#1
Thread Starter
Fanatic Member
Simple DLL...
I'm writing an application in Delphi which is going to be expandable by using DLL's for plugins. The Delphi part is not a problem obviously, but I want to make sure that it is compatible with C++ DLL's too.
I don't know much about C++, so I need one of you guys to do me a favour: write a very simple DLL which takes two parameters and shows them in a MessageBox.
The first parameter will be an 'HWND' type (which should cause no problems), but the second is a PChar (that's what it's called in Delphi, it's a pointer to the first character of a string, should be C++ compatible, *char or something like that?).
I only have Borland C++ Builder installed here, so I can compile it if it's compatible...
Thanks...
Teaudirenopossum.Musasapientumfixaestinaure.
(I can't hear you. There's a banana in my ear)
-
Nov 17th, 2001, 04:06 AM
#2
Sorry, I lost my sample dlls. I just can't remember how to do them.
Last edited by CornedBee; Nov 17th, 2001 at 04:33 AM.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 17th, 2001, 05:16 AM
#3
Thread Starter
Fanatic Member
...
I will go trough some tutorials if I can't get an answer here, but I don't want to learn C++ just for this, so if anyone has a sample though I would appreciate it a lot...
Teaudirenopossum.Musasapientumfixaestinaure.
(I can't hear you. There's a banana in my ear)
-
Nov 17th, 2001, 05:25 AM
#4
The function would look like this:
Code:
#include <windows.h>
void __stdcall ShowMB(HWND hwnd, char* str)
{
char buffer[200]; // or more if it produces failures
wsprintf(buffer, "Window: %d, String: %s", (int)hwnd, str);
MessageBox(NULL, buffer, "The DLL", MB_OK);
}
and you need a .def file that has this lines:
EXPORTS
ShowMB
But I forgot the exact def file syntax.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 17th, 2001, 05:54 AM
#5
Thread Starter
Fanatic Member
Thanks, that really helped me. Couldn't find the .def file thing, but the C++ Builder help had the solution:
Code:
#include <windows.h>
#pragma argsused
extern "C" __declspec(dllexport) void __stdcall test(HWND hWnd, char* pPath);
void __stdcall test(HWND hWnd, char* pPath)
{
char buffer[200];
wsprintf(buffer, "Window: %d\n\nPath: %s", (int)hWnd, pPath);
MessageBox(NULL, buffer, "DLL Test", MB_OK || MB_ICONINFORMATION);
}
That works fine, although the messagebox shows OK - CANCEL instead of just ok, MB_OK should be standard API, but anyways, it works so I can safely continue coding
Teaudirenopossum.Musasapientumfixaestinaure.
(I can't hear you. There's a banana in my ear)
-
Nov 17th, 2001, 08:23 AM
#6
Monday Morning Lunatic
MB_OK || MB_ICONINFORMATION
|| is the logical OR operator - it returns either true or false.
Use | instead, for a bitwise OR (which combines the bit values of the two operands).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 17th, 2001, 02:43 PM
#7
Yeah, and since MB_ICONEXCLAMATION is something > 0, it is evaluated as true which later becomes 1, which is MB_OKCANCEL.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|