[Webinar] Streamline your web hosting managementRegister Today


Making a .DLL

Posted on 1999-11-15
Medium Priority
Last Modified: 2010-04-16
I have a lot of experience programming in Visual Basic, however I would like to take dozens of functions that I have written in VB and make them into a C++ dll.  Now, I am just learning C++ and don't know the slightest bit about what I am doing.  If anyone could point me to a sample project with several different types of functions and return values, either on the web or email it to me (header@rocketmail.com) that would be great.

If I can see a sample, I should be able to modify it to fit my needs.
Question by:header
  • 3
  • 2
LVL 23

Accepted Solution

chensu earned 100 total points
ID: 2210082

Author Comment

ID: 2212389
I have taken the supplied demo from the msdn and added a function called 'Test'.

Here is my Select.def:

LIBRARY   Select

    StartSelection      @2
    UpdateSelection     @3
    EndSelection        @4
    ClearSelection      @5
    Test              @6

Here is my Select.h:

int APIENTRY StartSelection(HWND, MPOINT, LPRECT, int);
int APIENTRY UpdateSelection(HWND, MPOINT, LPRECT, int);
int APIENTRY ClearSelection(HWND, LPRECT, int);
int APIENTRY Test(long);

and here is Select.c

    long message)
      return message;

When I call this function from visual basic, it always returns -2328.  I'm not sure what I am doing wrong to make it return the wrong value.  It seems as though the value I pass to it from VB is not getting there, possibly from a wrong declaration somewhere?

Also, I put this line at the top of Select.c:
#include <iostream.h>

I tried to use this line in the Test function:
cout << "Hello World";

However, when I compiled it said 'cout' was an undeclared identifier.  What am I doing wrong there?
LVL 23

Expert Comment

ID: 2212575
>When I call this function from visual basic, it always returns -2328.

I don't use Visual Basic. You need to find out what the error code means.

>However, when I compiled it said 'cout' was an undeclared identifier.  What am I doing wrong there?

Your source file is in C language (.c). But cout is C++ stuff. Use printf instead.

Author Comment

ID: 2215081
I don't think I am getting an error message back.  If I say, for example:

return 12345;

VB returns the correct number (12345), the problem occurs when I change it to:

return message;

message is the parameter that was passed to the function, so I am wondering if there is something I did wrong to make the parameter not get passed or interpreted correctly.
LVL 23

Expert Comment

ID: 2218491
So, what did you get?

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question